/*
 ID: tommatt1
 LANG: JAVA
 TASK: 
*/
import java.util.*;
import java.io.*;
public class cf1361c implements Runnable{
static ArrayList<Integer>[] mod=new ArrayList[1<<20];
static pair[] val;
static int[] col;
static int n;
static ArrayList<Integer> ans;
static boolean[] vis;
static FastOutput out = new FastOutput(System.out);
static FastInput fs=new FastInput(System.in);
	public static void main(String[] args)throws InterruptedException, IOException{
		Thread t = new Thread(null, new cf1361c(), "cf1361c", 1 << 27);
        t.start();
        t.join();
        out.close();
	}
	public cf1361c() throws IOException{
		n=fs.readInt();
		val=new pair[n];
		for(int i=0;i<n;i++) {
			int a1=fs.readInt();
			int a2=fs.readInt();
			val[i]=new pair(a1,a2);
		}
	}
	public void run() {
		int hi=21;
		int lo=0;
		while(lo+1<hi) {
			int mid=(lo+hi)/2;
			if(pos(mid)) {
				lo=mid;
			}
			else {
				hi=mid;
			}
		}
		if(lo==0) {
			out.println(0);
			for(int i=1;i<=2*n;i++) {
				out.append(i).append(' ');
			}
			out.println();
			out.close();
			System.exit(0);
		}
		pos(lo);
		out.println(lo);
		for(int i=0;i<2*n;i++) {
			out.append(ans.get(i)+1).append(' ');
		}
		out.println();
		out.close();
		System.exit(0);
	}
	boolean pos(int z) {
		ans=new ArrayList<Integer>();
		mod=new ArrayList[1<<z];
		col=new int[2*n];
		vis=new boolean[2*n];
		for(int i=0;i<(1<<z);i++) {
			mod[i]=new ArrayList<Integer>();
		}
		for(int i=0;i<n;i++) {
			int a=val[i].a&(1<<z)-1;
			int b=val[i].b&(1<<z)-1;
			col[2*i]=a;
			col[2*i+1]=b;
			mod[a].add(2*i);
			mod[b].add(2*i+1);
		}
		for(int i=0;i<(1<<z);i++) {
			if(mod[i].size()%2==1) {
				return false;
			}
		}
		dfs(col[1]);
		if(ans.size()==2*n) {
			return true;
		}
		return false;
	}
	void dfs(int x) {
		while(!mod[x].isEmpty()) {
			int v=mod[x].remove(mod[x].size()-1);
			if(vis[v]) {
				continue;
			}
			vis[v]=vis[v^1]=true;
			dfs(col[v^1]);
			ans.add(v^1);
			ans.add(v);
		}
	}
	static class pair implements Comparable<pair>{
		int a,b;
		public pair(int x,int y) {
			a=x;b=y;
		}
		public int compareTo(pair p) {
			return a-p.a;
			//if(a>p.a) return 1;
		}
	}
	void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;
 
        public FastInput(InputStream is) {
            this.is = is;
        }
 
        public void populate(int[] data) {
            for (int i = 0; i < data.length; i++) {
                data[i] = readInt();
            }
        }
 
        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }
 
        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }
 
        public int readInt() {
            int sign = 1;
 
            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }
 
            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }
 
            return val;
        }
 
    }
 
    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;
 
        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }
 
        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }
 
        public FastOutput(Writer os) {
            this.os = os;
        }
 
        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }
 
        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }
 
        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }
 
        public FastOutput println(int c) {
            return append(c).println();
        }
 
        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }
 
        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }
 
        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }
 
        public String toString() {
            return cache.toString();
        }
 
    }
}
