#include <bits/stdc++.h>
using namespace std;
const int N = 2500000 + 100;
const long double pi = acos(-1.0);
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while ((ch < '0') || (ch > '9')) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ((ch >= '0') && (ch <= '9')) {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * f;
}
inline long long readll() {
  long long x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0') || (ch > '9')) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ((ch >= '0') && (ch <= '9')) {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * f;
}
int n, a[N], b[N], d[N], cur[N], ans = 0;
vector<int> rt;
bool vis[N << 1];
struct node {
  int to, nxt;
} sq[N << 1];
int all = 1, head[N];
void addedge(int u, int v) {
  all++;
  sq[all].to = v;
  sq[all].nxt = head[u];
  head[u] = all;
  d[u]++;
  vis[all] = 0;
}
void dfs(int u) {
  int i;
  while (head[u]) {
    i = head[u];
    head[u] = sq[i].nxt;
    int v = sq[i].to;
    if (vis[i]) continue;
    vis[i] = vis[i ^ 1] = 1;
    dfs(v);
    if ((u <= n * 2) && (v <= n * 2)) {
      rt.push_back(v);
      rt.push_back(u);
    }
  }
}
bool chk(int p) {
  int lim = (1 << p) - 1;
  all = 1;
  for (register int i = 1; i <= n * 2 + (1 << p); i++) {
    d[i] = 0;
    head[i] = 0;
  }
  for (register int i = 1; i <= n; i++) {
    int x = a[i] & lim, y = b[i] & lim;
    addedge(i * 2 - 1, x + n * 2 + 1);
    addedge(x + n * 2 + 1, i * 2 - 1);
    addedge(i * 2, y + n * 2 + 1);
    addedge(y + n * 2 + 1, i * 2);
  }
  for (register int i = 1; i <= n; i++) {
    addedge(i * 2 - 1, i * 2);
    addedge(i * 2, i * 2 - 1);
  }
  for (register int i = 1; i <= n * 2 + (1 << p); i++)
    if (d[i] & 1) return 0;
  for (register int i = 1; i <= n * 2 + (1 << p); i++) cur[i] = head[i];
  rt.clear();
  dfs(1);
  int len = rt.size();
  if (len < n * 2) return 0;
  return 1;
}
void out() {
  chk(ans);
  for (register int i = 1; i <= n * 2; i++) printf("%d ", rt[i - 1]);
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) {
    a[i] = read();
    b[i] = read();
  }
  ans = 20;
  for (register int p = 1; p <= 20; p++) {
    if (!chk(p)) {
      ans = p - 1;
      break;
    }
  }
  printf("%d\n", ans);
  if (ans == 0) {
    for (register int i = 1; i <= n; i++) printf("%d %d ", i * 2 - 1, i * 2);
  } else
    out();
  return 0;
}
