#include <bits/stdc++.h>
using namespace std;
const long long dx[] = {0, 1, 0, -1};
const long long dy[] = {1, 0, -1, 0};
const long long inf = 0x3f3f3f3f3f3f3f;
const long long mod = 1e9 + 7;
const long long N = 1e6 + 11;
const long long NMAX = 1e4 + 11;
const long long INF64 = 3e18 + 1;
const double lil = 0.0000000000001;
long long t, n, m, cd[N], x[N], y[N], viz[N];
vector<long long> v[1 << 22], ans;
void restore(long long i) {
  while ((long long)((v[i]).size())) {
    auto it = v[i].back();
    v[i].pop_back();
    if (viz[it]) continue;
    long long another = (it & 1 ? it + 1 : it - 1);
    viz[it] = 1;
    viz[another] = 1;
    restore(cd[it]);
    ans.push_back(it);
    ans.push_back(another);
  }
}
bool check(long long P) {
  memset(viz, 0, sizeof(viz));
  ans.clear();
  for (long long i = 1; i <= n; i++) {
    v[x[i]].clear();
    v[y[i]].clear();
  }
  for (long long i = 1; i <= n; i++) {
    v[x[i]].push_back(2 * i);
    v[y[i]].push_back(2 * i - 1);
    cd[2 * i - 1] = x[i];
    cd[2 * i] = y[i];
  }
  for (long long i = 1; i <= n; i++) {
    if ((long long)((v[x[i]]).size()) % 2 || (long long)((v[y[i]]).size()) % 2)
      return 0;
  }
  restore(cd[1]);
  if ((long long)((ans).size()) == 2 * n) return 1;
  return 0;
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
  }
  for (long long i = 20; i >= 0; i--) {
    for (long long j = 1; j <= n; j++) {
      x[j] &= ((1 << i) - 1);
      y[j] &= ((1 << i) - 1);
    }
    if (check(i)) {
      cout << i << '\n';
      for (auto it : ans) cout << it << ' ';
      return 0;
    }
  }
}
