#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<array<int, 2>> parts(n);
  for (int i = 0; i < n; i++) {
    cin >> parts[i][0] >> parts[i][1];
  }
  for (int bt = 20; bt > 0; bt--) {
    int cnt = 1 << bt;
    int msk = cnt - 1;
    vector<vector<array<int, 2>>> g(cnt);
    for (int i = 0; i < n; i++) {
      int v1 = parts[i][0] & msk;
      int v2 = parts[i][1] & msk;
      g[v1].push_back({v2, i});
      g[v2].push_back({v1, i});
    }
    bool ok = true;
    for (int i = 0; i < cnt && ok; i++) {
      if (g[i].size() % 2 != 0) ok = false;
    }
    if (!ok) {
      continue;
    }
    vector<bool> vis(n);
    auto get_loop = [&](int p) {
      list<int> loop;
      while (g[p].size() > 0) {
        int pn = g[p].back()[0];
        int en = g[p].back()[1];
        if (vis[en]) {
          g[p].pop_back();
          continue;
        }
        vis[en] = true;
        if ((parts[en][0] & msk) == p) {
          loop.push_back(2 * en + 1);
          loop.push_back(2 * en + 2);
        } else {
          loop.push_back(2 * en + 2);
          loop.push_back(2 * en + 1);
        }
        g[p].pop_back();
        p = pn;
      }
      return loop;
    };
    list<int> res = get_loop(parts[0][0] & msk);
    for (auto p = res.begin(); p != res.end(); p++) {
      int idx = *p - 1;
      int v = parts[idx >> 1][idx & 1] & msk;
      if (g[v].size() > 0) {
        auto loop = get_loop(v);
        auto it = p;
        it++;
        res.insert(it, loop.begin(), loop.end());
      }
    }
    if (res.size() == 2 * n) {
      cout << bt << endl;
      for (auto w : res) cout << w << " ";
      cout << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  for (int i = 1; i <= 2 * n; i++) cout << i << " ";
  cout << endl;
  return 0;
}
