#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long inf64 = 1e18;
const int LOG = 20;
const int N = 1 << LOG;
int n;
int a[N], b[N];
vector<pair<int, int> > g[N];
int used[N];
void clr(int v) {
  while (!g[v].empty() && used[g[v].back().second]) {
    g[v].pop_back();
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  n *= 2;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int k = LOG; k >= 0; k--) {
    int t = (1 << k) - 1;
    for (int i = 0; i < n; i++) b[i] = a[i] & t;
    for (int i = 0; i < n; i++) g[b[i]].emplace_back(b[i ^ 1], i);
    int ok = 1;
    for (int x = 0; x < N; x++) {
      if ((int)g[x].size() & 1) {
        ok = 0;
        break;
      }
    }
    if (ok) {
      vector<int> order;
      vector<pair<int, int> > st;
      st.emplace_back(b[0], -1);
      while (!st.empty()) {
        int v, id;
        tie(v, id) = st.back();
        clr(v);
        if (g[v].empty()) {
          if (id != -1) order.push_back(id ^ 1);
          st.pop_back();
        } else {
          int to, eid;
          tie(to, eid) = g[v].back();
          used[eid] = used[eid ^ 1] = 1;
          st.emplace_back(to, eid);
        }
      }
      if ((int)order.size() * 2 == n) {
        cout << k << "\n";
        for (int v : order) {
          cout << v + 1 << " " << (v ^ 1) + 1 << " ";
        }
        cout << "\n";
        return 0;
      }
    }
    for (int i = 0; i < n; i++) {
      g[b[i]].clear();
      used[i] = 0;
    }
  }
  return 0;
}
