#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5;
const int MAXS = 1 << 20;
int n, a[MAXN + 5], b[MAXN + 5], deg[MAXS + 5];
struct EDGE {
  int nxt, to;
} edge[MAXN * 4 + 5];
int head[MAXN + MAXS + 10], tot;
inline void add_edge(int u, int v) {
  edge[++tot].nxt = head[u], edge[tot].to = v, head[u] = tot;
}
int sta[MAXN * 4 + 5], top;
bool vis[MAXN * 4 + 5];
void dfs(int u) {
  for (int& i = head[u]; i; i = edge[i].nxt) {
    if (!vis[i]) {
      vis[i] = vis[i ^ 1] = 1;
      int v = edge[i].to;
      dfs(v);
      sta[++top] = v;
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
  }
  for (int i = 20; i >= 1; --i) {
    int S = (1 << i) - 1;
    for (int j = 0; j <= S; ++j) deg[j] = 0;
    for (int j = 1; j <= n; ++j) {
      deg[a[j] & S]++;
      deg[b[j] & S]++;
    }
    bool fail = false;
    for (int j = 0; j <= S; ++j)
      if (deg[j] & 1) {
        fail = true;
        break;
      }
    if (fail) continue;
    for (int i = 1; i <= tot; ++i) vis[i] = 0;
    tot = 1;
    for (int j = 1; j <= S + n + 1; ++j) head[j] = 0;
    for (int j = 1; j <= n; ++j) {
      add_edge(j, (a[j] & S) + n + 1);
      add_edge((a[j] & S) + n + 1, j);
      add_edge(j, (b[j] & S) + n + 1);
      add_edge((b[j] & S) + n + 1, j);
    }
    top = 0;
    dfs(1);
    int cnt = 0;
    for (int j = 1; j <= top; ++j) cnt += (sta[j] <= n);
    if (cnt != n) continue;
    cout << i << endl;
    for (int j = 1; j <= top; ++j) {
      if (sta[j] <= n) {
        assert(j < top && sta[j + 1] > n);
        int s = (sta[j + 1] - (n + 1));
        int id = sta[j];
        assert((a[id] & S) == s || (b[id] & S) == s);
        if ((a[id] & S) == s) {
          cout << id * 2 << " " << id * 2 - 1 << " ";
        } else {
          cout << id * 2 - 1 << " " << id * 2 << " ";
        }
      }
    }
    cout << endl;
    return 0;
  }
  cout << 0 << endl;
  for (int i = 1; i <= n * 2; ++i) cout << i << " ";
  cout << endl;
  return 0;
}
