#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
int n;
int part[N][2];
bool vis[N];
vector<int> ans;
vector<pair<int, int> > G[N];
void dfs(int u) {
  vis[u] = true;
  for (auto v : G[u])
    if (!vis[v.first]) dfs(v.first);
}
bool check(int Mask) {
  for (int i = 0; i <= Mask; ++i) G[i].clear(), vis[i] = false;
  for (int i = 1; i <= n; ++i) {
    int u = part[i][0] & Mask;
    int v = part[i][1] & Mask;
    G[u].push_back({v, 2 * i - 1});
    G[v].push_back({u, 2 * i - 2});
  }
  int comps = 0;
  for (int i = 0; i <= Mask; ++i) {
    if (G[i].size() & 1) return false;
    if (!vis[i] && G[i].size() > 0) {
      ++comps;
      dfs(i);
    }
  }
  return comps == 1;
}
void go(int u, int prv = -1) {
  while (G[u].size()) {
    auto e = G[u].back();
    G[u].pop_back();
    if (vis[e.second / 2]) continue;
    vis[e.second / 2] = true;
    go(e.first, e.second);
  }
  if (prv != -1) {
    ans.push_back(prv);
    ans.push_back(prv ^ 1);
  }
}
void restore(int Mask) {
  for (int i = 0; i <= n; ++i) vis[i] = false;
  for (int i = 0; i <= Mask; ++i)
    if (G[i].size()) {
      go(i);
      break;
    }
  for (int i = 0; i < n + n; ++i)
    printf("%d%c", ans[i] + 1, " \n"[i + 1 == n + n]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d %d", &part[i][0], &part[i][1]);
  for (int i = 20; i >= 0; --i)
    if (check((1 << i) - 1)) {
      printf("%d\n", i);
      restore((1 << i) - 1);
      exit(0);
    }
  assert(false);
  return 0;
}
