#include <bits/stdc++.h>
using namespace std;
int n;
int const N = 1 << 20;
vector<pair<int, int> > edges(N), g[N];
vector<bool> used(N);
vector<int> ans;
void dfs(int c) {
  used[c] = 1;
  for (auto v : g[c]) {
    if (!used[v.first]) {
      dfs(v.first);
    }
  }
}
bool check(int Mask) {
  for (int i = 0; i <= Mask; i++) {
    g[i].clear();
    used[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    int u = edges[i].first & Mask;
    int v = edges[i].second & Mask;
    g[u].push_back({v, 2 * i + 1});
    g[v].push_back({u, 2 * i});
  }
  int comp = 0;
  for (int i = 0; i <= Mask; i++) {
    if (g[i].size() & 1) {
      return 0;
    }
    if (!used[i] && g[i].size() > 0) {
      comp++;
      dfs(i);
    }
  }
  return comp == 1;
}
void go(int u, int p = -1) {
  while (g[u].size()) {
    auto e = g[u].back();
    g[u].pop_back();
    if (used[e.second / 2]) continue;
    used[e.second / 2] = 1;
    go(e.first, e.second);
  }
  if (p != -1) {
    ans.push_back(p);
    ans.push_back(p ^ 1);
  }
}
void restore(int Mask) {
  for (int i = 0; i <= n; i++) {
    used[i] = 0;
  }
  for (int i = 0; i <= Mask; i++) {
    if (g[i].size()) {
      go(i);
      break;
    }
  }
  for (int i = 0; i < 2 * n; i++) cout << ans[i] + 1 << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> edges[i].first >> edges[i].second;
  }
  for (int b = 20; b >= 0; b--) {
    if (check((1 << b) - 1)) {
      cout << b << endl;
      restore((1 << b) - 1);
      return 0;
    }
  }
  return 0;
}
