#include <bits/stdc++.h>
using namespace std;
const int MAXN = (1 << 20) + 5;
bool used[MAXN];
vector<int> adj[MAXN];
int a[MAXN];
int n;
vector<int> ans;
vector<int>::iterator it[MAXN];
void dfs(int x) {
  while (it[x] != adj[x].end()) {
    int p = *(it[x]);
    if (!used[p / 2]) {
      int p = *(it[x]);
      it[x]++;
      used[p / 2] = true;
      dfs(a[p ^ 1]);
      ans.push_back(p);
    } else {
      it[x]++;
    }
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < 2 * n; i++) cin >> a[i];
  for (int i = 0; i < 2 * n; i++) used[a[i]] = !used[a[i]];
  int k;
  for (k = 20; k >= 0; k--) {
    bool good = true;
    for (int i = 0; i < (1 << k); i++) {
      if (used[i]) {
        good = false;
        break;
      }
    }
    if (good) break;
    for (int i = 0; i < (1 << (k - 1)); i++) {
      used[i] = used[i] ^ used[i + (1 << (k - 1))];
    }
  }
  for (; k >= 0; k--) {
    for (int i = 0; i < n; i++) {
      used[i] = false;
    }
    for (int i = 0; i < 2 * n; i++) {
      a[i] = a[i] % (1 << k);
    }
    for (int i = 0; i < (1 << k); i++) adj[i].clear();
    for (int i = 0; i < n; i++) {
      adj[a[2 * i]].push_back(2 * i);
      adj[a[2 * i + 1]].push_back(2 * i + 1);
    }
    for (int i = 0; i < (1 << k); i++) {
      it[i] = adj[i].begin();
    }
    dfs(a[0]);
    if (ans.size() == n) {
      cout << k << "\n";
      for (int i = n - 1; i >= 0; i--) {
        cout << 1 + ans[i] << " " << 1 + (ans[i] ^ 1) << " ";
      }
      return 0;
    }
    ans.clear();
  }
}
