#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 10;
int n, cnt, tot;
int a[maxn], b[maxn], c[maxn], d[maxn];
int fa[maxn];
int du[maxn];
int nxt[maxn], first[maxn], go[maxn], visit[maxn];
int sta[maxn];
void comb(int a, int b) { nxt[++tot] = first[a], first[a] = tot, go[tot] = b; }
void dfs1(int u) {
  for (int &e = first[u]; e; e = nxt[e]) {
    if (!visit[e]) {
      visit[e] = true;
      if (e % 2 == 1)
        visit[e + 1] = true;
      else
        visit[e - 1] = true;
      int t = e;
      dfs1(go[e]);
      sta[++cnt] = t;
    }
  }
}
int find(int x) {
  if (x == fa[x]) return x;
  return fa[x] = find(fa[x]);
}
void wk(int xx, int x) {
  for (int i = 1; i <= n; i++) c[i] = a[i] % x, d[i] = b[i] % x;
  for (int i = 0; i < maxn; i++) fa[i] = i, du[i] = 0;
  int bel = -1;
  for (int i = 1; i <= n; i++) {
    du[c[i]]++;
    du[d[i]]++;
    int fx = find(c[i]);
    int fy = find(d[i]);
    if (fx != fy) fa[fx] = fy;
  }
  for (int i = 0; i < maxn; i++) {
    if (du[i] == 0) continue;
    if (du[i] % 2) return;
    if (bel == -1) bel = find(i);
    int tmp = find(i);
    if (tmp != bel) return;
  }
  for (int i = 1; i <= n; i++) {
    c[i]++, d[i]++;
    comb(c[i], d[i]);
    comb(d[i], c[i]);
  }
  for (int i = 0; i < maxn; i++) {
    if (first[i]) {
      dfs1(i);
      break;
    }
  }
  printf("%d\n", xx);
  for (int i = cnt; i >= 1; i--) {
    if (sta[i] % 2 == 1) {
      int tmp = (sta[i] + 1) / 2 * 2;
      printf("%d %d ", tmp - 1, tmp);
    } else {
      int tmp = sta[i] / 2 * 2;
      printf("%d %d ", tmp, tmp - 1);
    }
  }
  exit(0);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i], &b[i]);
  for (int i = 20; i >= 0; i--) wk(i, (1 << i));
  return 0;
}
