#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
int n, a[maxn], b[maxn];
signed main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", a + i, b + i);
  for (int k = 20; ~k; k--) {
    int t = 1 << k;
    vector<vector<pair<int, int> > > g(t + n + 5);
    for (int i = 0; i < n; i++) {
      g[a[i] & (t - 1)].push_back({i + t, 2 * i + 1});
      g[i + t].push_back({a[i] & (t - 1), 2 * i + 1});
      g[b[i] & (t - 1)].push_back({i + t, 2 * i + 2});
      g[i + t].push_back({b[i] & (t - 1), 2 * i + 2});
    }
    bool ok = 1;
    for (int i = 0; i < t + n; i++)
      if (g[i].size() & 1) ok = 0;
    if (!ok) continue;
    vector<bool> del(2 * n + 5);
    vector<int> ans;
    function<void(int, int)> dfs = [&](int u, int fa) {
      while (g[u].size()) {
        auto it = g[u].back();
        g[u].pop_back();
        int v = it.first, id = it.second;
        if (!del[id]) {
          del[id] = true;
          dfs(v, id);
        }
      }
      if (fa != -1) ans.push_back(fa);
    };
    for (int i = 0; i < t + n; i++)
      if (g[i].size()) {
        dfs(i, -1);
        break;
      }
    if (ans.size() != 2 * n) continue;
    printf("%d\n", k);
    for (int i = ans.size() - 1; ~i; i--) printf("%d ", ans[i]);
    break;
  }
}
