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