Problem: Johnny's younger sister Megan had a birthday recently. Her brother has bought her a box signed as "Your beautiful necklace — do it yourself!". It contains many necklace parts and some magic glue. 

The necklace part is a chain connecting two pearls. Color of each pearl can be defined by a non-negative integer. The magic glue allows Megan to merge two pearls (possibly from the same necklace part) into one. The beauty of a connection of pearls in colors u and v is defined as follows: let 2^k be the greatest power of two dividing u ⊕ v — [exclusive or](https://en.wikipedia.org/wiki/Exclusive_or#Computer_science) of u and v. Then the beauty equals k. If u = v, you may assume that beauty is equal to 20.

Each pearl can be combined with another at most once. Merging two parts of a necklace connects them. Using the glue multiple times, Megan can finally build the necklace, which is a cycle made from connected necklace parts (so every pearl in the necklace is combined with precisely one other pearl in it). The beauty of such a necklace is the minimum beauty of a single connection in it. The girl wants to use all available necklace parts to build exactly one necklace consisting of all of them with the largest possible beauty. Help her!

Input

The first line contains n (1 ≤ n ≤ 5 ⋅ 10^5) — the number of necklace parts in the box. Each of the next n lines contains two integers a and b (0 ≤ a, b < 2^{20}), which denote colors of pearls presented in the necklace parts. Pearls in the i-th line have indices 2i - 1 and 2i respectively.

Output

The first line should contain a single integer b denoting the maximum possible beauty of a necklace built from all given parts.

The following line should contain 2n distinct integers p_i (1 ≤ p_i ≤ 2n) — the indices of initial pearls in the order in which they appear on a cycle. Indices of pearls belonging to the same necklace part have to appear at neighboring positions in this permutation (so 1 4 3 2 is not a valid output, whereas 2 1 4 3 and 4 3 1 2 are). If there are many possible answers, you can print any.

Examples

Input


5
13 11
11 1
3 5
17 1
9 27


Output


3
8 7 9 10 5 6 1 2 3 4 


Input


5
13 11
11 1
3 5
17 1
7 29


Output


2
8 7 10 9 5 6 4 3 2 1 


Input


1
1 1


Output


20
2 1 

Note

In the first example the following pairs of pearls are combined: (7, 9), (10, 5), (6, 1), (2, 3) and (4, 8). The beauties of connections equal correspondingly: 3, 3, 3, 20, 20.

The following drawing shows this construction.

<image>

Solution (in JAVA):

Solution:
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Locale;
import java.util.StringTokenizer;

public class HackerRank implements Runnable {
	
	private PrintStream out;
	private BufferedReader in;
	private StringTokenizer st;
	
	public void solve() throws IOException {
		long time0 = System.currentTimeMillis();
		
		int n = nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
			b[i] = nextInt();
		}
		String answer = solve(n, a, b);
		out.println(answer);
		
		System.err.println("time: " + (System.currentTimeMillis() - time0));
	}
	
	private String solve(int n, int[] a, int[] b) {
		int l = 0;
		int r = 21;
		while (l + 1 < r) {
			int m = (l + r) / 2;
			if (canSolve(m, n, a, b)) {
				l = m;
			} else {
				r = m;
			}
		}
		String answer = solve(l, n, a, b);
		StringBuilder buf = new StringBuilder();
		buf.append(l + "\n");
		buf.append(answer);
		return buf.toString();
	}

	private String solve(int k, int n, int[] a, int[] b) {
		StringBuilder buf = new StringBuilder();
		int[][][] edges = buildEdges(k, n, a, b);
		int[][][] g = buildGraph(1 << k, edges);
		int[] gdone = new int[g.length];
		int[] node = new int[2 * n];
		String[] exit = new String[node.length];
		int cnt = 0;
		boolean[] visited = new boolean[n];
		node[cnt] = edges[0][0][0];
		exit[cnt] = "";
		cnt++;
		while (cnt > 0) {
			int curNode = node[cnt - 1];
			int curDone = gdone[curNode];
			if (curDone == g[curNode].length) {
				buf.append(exit[cnt - 1]).append(' ');
				cnt--;
				continue;
			}
			gdone[curNode]++;
			if (!visited[g[curNode][curDone][1]]) {
				node[cnt] = g[curNode][curDone][0];
				int z = edges[g[curNode][curDone][1]][0][1];
				int x = edges[g[curNode][curDone][1]][1][1];
				if (g[curNode][curDone][2] == 0) {
					int y = z;
					z = x;
					x = y;
				}
				exit[cnt] = z + " " + x;
				cnt++;
				visited[g[curNode][curDone][1]] = true;
			}
		}
		return buf.toString();
	}

	private int[][][] buildGraph(int n, int[][][] edges) {
		int[] cnt = new int[n];
		for (int i = 0; i < edges.length; i++) {
			cnt[edges[i][0][0]]++;
			cnt[edges[i][1][0]]++;
		}
		int[][][] g = new int[n][][];
		for (int i = 0; i < n; i++) {
			g[i] = new int[cnt[i]][3];
			cnt[i] = 0;
		}
		for (int i = 0; i < edges.length; i++) {
			int u = edges[i][0][0];
			int v = edges[i][1][0];
			g[u][cnt[u]][0] = v;
			g[u][cnt[u]][1] = i;
			g[u][cnt[u]][2] = 0;
			cnt[u]++;
			g[v][cnt[v]][0] = u;
			g[v][cnt[v]][1] = i;
			g[v][cnt[v]][2] = 1;
			cnt[v]++;
		}
		return g;
	}

	private boolean canSolve(int k, int n, int[] a, int[] b) {
		int[][][] edges = buildEdges(k, n, a, b);
		int[] cnt = new int[1 << k];
		DSS dss = new DSS(1 << k);
		for (int i = 0; i < n; i++) {
			cnt[edges[i][0][0]]++;
			cnt[edges[i][1][0]]++;
			dss.join(edges[i][0][0], edges[i][1][0]);
		}
		int father = dss.get(edges[0][0][0]);
		for (int i = 0; i < cnt.length; i++) {
			if (cnt[i] > 0) {
				if (cnt[i] % 2 != 0) {
					return false;
				}
				if (dss.get(i) != father) {
					return false;
				}
			}
		}
		return true;
	}
	
	public class DSS {
		private int[] size;
		private int[] father;
		public DSS(int n) {
			size = new int[n];
			father = new int[n];
			for (int i = 0; i < n; i++) {
				father[i] = i;
				size[i] = 1;
			}
		}
		public int get(int u) {
			ArrayList<Integer> buf = new ArrayList<>();
			while (father[u] != u) {
				buf.add(u);
				u = father[u];
			}
			for (int v : buf) {
				father[v] = u;
			}
			return u;
		}
		public void join(int u, int v) {
			u = get(u);
			v = get(v);
			if (u == v) {
				return;
			}
			if (size[u] < size[v]) {
				father[u] = v;
				size[u] += size[v];
			} else {
				father[v] = u;
				size[v] += size[u];
			}
		}
	}

	private int[][][] buildEdges(int k, int n, int[] a, int[] b) {
		int kmask = (1 << k) - 1;
		int[][][] result = new int[n][2][2];
		for (int i = 0; i < n; i++) {
			result[i][0][0] = a[i] & kmask;
			result[i][0][1] = 2 * i + 1;
			result[i][1][0] = b[i] & kmask;
			result[i][1][1] = 2 * i + 2;
		}
		return result;
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	
	public long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	
	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	public String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			st = new StringTokenizer(line);
		}
		return st.nextToken();
	}
	
	@Override
	public void run() {
		try {
			solve();
			out.close();
		} catch (Throwable e) {
			throw new RuntimeException(e);
		}
	}
	
	public HackerRank(String name) throws IOException {
		Locale.setDefault(Locale.US);
		if (name == null) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintStream(new BufferedOutputStream(System.out));
		} else {
			in = new BufferedReader(new InputStreamReader(new FileInputStream(name + ".in")));
			out = new PrintStream(new BufferedOutputStream(new FileOutputStream(name + ".out")));
		}
		st = new StringTokenizer("");
	}
	
	public static void main(String[] args) throws IOException {
		new Thread(new HackerRank(null)).start();
	}
}