#include <bits/stdc++.h>
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
  std::cout << a << ' ';
  err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &...args) {
  for (auto &v : arg) std::cout << v << ' ';
  err(args...);
}
using namespace std;
const int N = 5e5 + 5;
void run() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for (int k = 20; k >= 0; k--) {
    int t = 1 << k;
    vector<vector<pair<int, int>>> G(t + n);
    for (int i = 0; i < n; i++) {
      G[a[i] & (t - 1)].push_back(make_pair(i + t, 2 * i));
      G[i + t].push_back(make_pair(a[i] & (t - 1), 2 * i));
      G[b[i] & (t - 1)].push_back(make_pair(i + t, 2 * i + 1));
      G[i + t].push_back(make_pair(b[i] & (t - 1), 2 * i + 1));
    }
    bool ok = true;
    for (int i = 0; i < t; i++) {
      if ((int)(G[i]).size() & 1) {
        ok = false;
        break;
      }
    }
    if (ok == false) continue;
    vector<bool> del(2 * n);
    vector<int> ans;
    function<void(int, int)> dfs = [&](int u, int from) {
      while ((int)(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 (from != -1) ans.push_back(from);
    };
    ans.clear();
    for (int i = 0; i < n + t; i++) {
      if ((int)(G[i]).size()) {
        dfs(i, -1);
        break;
      }
    }
    if ((int)(ans).size() < 2 * n) {
      continue;
    }
    cout << k << '\n';
    for (auto it : ans) {
      cout << it + 1 << ' ';
    }
    cout << '\n';
    break;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  run();
  return 0;
}
