#include <bits/stdc++.h>
using namespace std;
int n;
int arr[(int(5e5) + 7) * 2];
int d[((1 << 20) + 7)];
int hd[((1 << 20) + 7)], to[((1 << 20) + 7) * 2], nxt[((1 << 20) + 7) * 2],
    toori[((1 << 20) + 7) * 2], en;
bool vis[((1 << 20) + 7)];
vector<int> vt[((1 << 20) + 7)];
inline void adde(int a, int b, int c) {
  nxt[en] = hd[a];
  hd[a] = en;
  to[en] = b;
  toori[en] = c;
  en++;
}
vector<int> ansv;
bool vis2[((1 << 20) + 7)];
void euler(int u) {
  for (int& i = hd[u]; ~i; i = nxt[i])
    if (!vis[i / 2]) {
      int t = i;
      vis[i / 2] = 1;
      int v = to[i];
      euler(v);
      int o = toori[t];
      ansv.push_back(o + 1);
      ansv.push_back((o ^ 1) + 1);
      if (i == -1) break;
    }
}
void dfs(int x) {
  vis[x] = 1;
  for (int i = hd[x]; ~i; i = nxt[i])
    if (!vis[to[i]]) {
      dfs(to[i]);
    }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i * 2] >> arr[i * 2 + 1];
  }
  int ans = 0;
  unsigned k = 1;
  memset(hd, -1, sizeof hd);
  memset(d, 0, sizeof d);
  for (; ans < 20; k = 1 | (k << 1), ans++) {
    en = 0;
    for (int i = 0; i < n; i++) {
      unsigned u = arr[i * 2] & k, v = arr[i * 2 + 1] & k;
      adde(u, v, i * 2 + 1), adde(v, u, i * 2);
      d[u]++, d[v]++;
      vis[u] = 0, vis[v] = 0;
    }
    bool ok = true;
    for (int i = 0; i < n; i++) {
      unsigned u = arr[i * 2] & k, v = arr[i * 2 + 1] & k;
      if ((d[u] & 1) || (d[v] & 1)) {
        ok = false;
        break;
      }
    }
    if (!ok) break;
    int conn = 0;
    for (int i = 0; i < n * 2; i++) {
      unsigned u = arr[i] & k;
      if (!vis[u]) {
        conn++;
        dfs(u);
      }
    }
    if (conn != 1) break;
    for (int i = 0; i < n; i++) {
      unsigned u = arr[i * 2] & k, v = arr[i * 2 + 1] & k;
      d[u] = 0, d[v] = 0;
      hd[u] = -1, hd[v] = -1;
    }
  }
  k >>= 1;
  cout << ans << '\n';
  en = 0;
  memset(hd, -1, sizeof hd);
  memset(vis2, 0, sizeof vis2);
  memset(vis, 0, sizeof vis);
  for (unsigned i = 0; i < n; i++) {
    unsigned u = arr[i * 2] & k, v = arr[i * 2 + 1] & k;
    adde(u, v, i * 2 + 1), adde(v, u, i * 2);
  }
  for (unsigned j = 0; j < n * 2; j++) {
    int i = arr[j] & k;
    if (~hd[i] && !vis[hd[i] / 2]) {
      euler(i);
    }
  }
  for (size_t i = 0; i < ansv.size(); i++) {
    cout << ansv[i] << " \n"[i + 1 == ansv.size()];
  }
}
