#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int num[1000005], n;
vector<pair<int, int>> g[1 << 20 | 1], ans;
bool used[1 << 20 | 1];
void DFS(int v) {
  used[v] = 1;
  for (auto x : g[v])
    if (!used[x.first]) DFS(x.first);
}
bool check(int v) {
  int i;
  for (i = 0; i <= v; i++) {
    used[i] = 0;
    g[i].clear();
  }
  for (i = 0; i < n; i++) {
    int f = num[i << 1] & v, t = num[i << 1 | 1] & v;
    g[f].emplace_back(t, i << 1 | 1);
    g[t].emplace_back(f, i << 1);
  }
  int comp = 0;
  for (i = 0; i <= v; i++) {
    if ((int)g[i].size() & 1) return 0;
    if (!used[i] && g[i].size()) {
      comp++;
      DFS(i);
    }
  }
  return comp == 1;
}
void Euler_Cycle(int v) {
  while (g[v].size()) {
    auto x = g[v].back();
    g[v].pop_back();
    if (used[x.second]) continue;
    if (x.second & 1) {
      used[x.second] = used[x.second - 1] = 1;
      Euler_Cycle(x.first);
      ans.emplace_back(x.second, x.second + 1);
    } else {
      used[x.second] = used[x.second + 1] = 1;
      Euler_Cycle(x.first);
      ans.emplace_back(x.second + 2, x.second + 1);
    }
  }
}
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d%d", &num[i << 1], &num[i << 1 | 1]);
  for (i = 20; i >= 0; i--) {
    if (check((1 << i) - 1)) {
      printf("%d\n", i);
      for (j = 0; j < n; j++) used[j << 1] = used[j << 1 | 1] = 0;
      for (j = 0; j <= (1 << i) - 1; j++)
        if (g[j].size()) {
          Euler_Cycle(j);
          reverse(ans.begin(), ans.end());
          for (auto x : ans) printf("%d %d ", x.first, x.second);
          return 0;
        }
    }
  }
}
