#include <bits/stdc++.h>
using namespace std;
const int MAXN = (1 << 20) + 5;
bool used[MAXN];
list<int> adj[MAXN];
int a[MAXN];
int n;
void dfs() {
  stack<int> st;
  st.push(1);
  while (!st.empty()) {
    int next = a[st.top() ^ 1];
    while (!adj[next].empty() and used[adj[next].back() / 2]) {
      adj[next].pop_back();
    }
    if (adj[next].empty()) {
      int p = st.top();
      if (st.size() > 1) {
        cout << 1 + (p ^ 1) << " " << 1 + p << " ";
      }
      st.pop();
    } else {
      int p = adj[next].back();
      adj[next].pop_back();
      st.push(p);
      used[p / 2] = true;
    }
  }
}
int pt[1 << 20];
bool occ[1 << 20];
int findset(int x) {
  while (x != pt[x]) {
    pt[x] = pt[pt[x]];
    x = pt[x];
  }
  return x;
}
int component = 0;
void onion(int x, int y) {
  x = findset(x);
  y = findset(y);
  if (x != y) {
    pt[x] = y;
    component--;
  }
}
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];
    used[a[i]] = !used[a[i]];
  }
  for (int i = 0; i < n; i++) onion(a[2 * i], a[2 * i + 1]);
  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--) {
    component = 0;
    for (int i = 0; i < 2 * n; i++) {
      a[i] = a[i] % (1 << k);
      if (!occ[a[i]]) {
        occ[a[i]] = true;
        pt[a[i]] = a[i];
        component++;
      }
    }
    for (int i = 0; i < n; i++) onion(a[2 * i], a[2 * i + 1]);
    for (int i = 0; i < 2 * n; i++) {
      occ[a[i]] = false;
    }
    if (component == 1) break;
  }
  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 < n; i++) {
    adj[a[2 * i]].push_back(2 * i);
    adj[a[2 * i + 1]].push_back(2 * i + 1);
  }
  cout << k << "\n";
  dfs();
  return 0;
}
