#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
int n, ncomp, pre[N], __nico_rank[N], deg[N];
vector<pair<int, int> > e;
int find(int x) { return pre[x] = (pre[x] == x ? x : find(pre[x])); }
bool merge(int x, int y) {
  auto a = find(x), b = find(y);
  if (a == b) return false;
  if (__nico_rank[a] < __nico_rank[b]) swap(a, b);
  pre[b] = a;
  __nico_rank[a] += __nico_rank[b];
  return true;
}
bool check(int k) {
  if (ncomp > 1) return false;
  for (int i = 0; i < (int)(1 << k); i++)
    if (deg[i] % 2) return false;
  return true;
}
vector<int> tour;
vector<pair<int, int> > adj[N];
bool dead[N];
void dfs(int u, int p) {
  while (!adj[u].empty()) {
    auto vp = adj[u].back();
    adj[u].pop_back();
    int v = vp.first;
    int idx = vp.second;
    if (dead[idx / 2]) continue;
    dead[idx / 2] = true;
    dfs(v, idx);
  }
  tour.push_back(p);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  iota(pre, pre + N, 0);
  fill_n(__nico_rank, N, 1);
  cin >> n;
  e.resize(n);
  set<int> nodes;
  for (int i = 0; i < (int)(n); i++) {
    int u, v;
    cin >> u >> v;
    ncomp -= merge(u, v);
    e[i] = {u, v};
    deg[u]++;
    deg[v]++;
    nodes.insert(u);
    nodes.insert(v);
  }
  ncomp += ((int)(nodes).size());
  int k;
  for (k = 20; k >= 0; k--) {
    if (check(k)) break;
    int half = 1 << (k - 1);
    for (int mask = (int)(half); mask < ((int)2 * half); mask++) {
      if (merge(mask, mask - half) && deg[mask] && deg[mask - half]) {
        --ncomp;
      }
      deg[mask - half] += deg[mask];
    }
  }
  cout << k << endl;
  int mask = (1 << k) - 1;
  for (int i = 0; i < (int)(n); i++) {
    int u, v;
    tie(u, v) = e[i];
    u &= mask;
    v &= mask;
    adj[u].emplace_back(v, 2 * i);
    adj[v].emplace_back(u, 2 * i + 1);
  }
  dfs(e[0].first & mask, -1);
  assert(tour.back() == -1);
  tour.pop_back();
  reverse((tour).begin(), (tour).end());
  vector<int> ans;
  for (auto idx : tour) {
    ans.push_back(1 + idx);
    ans.push_back(1 + (idx ^ 1));
  }
  for (auto x : ans) cout << x << ' ';
  return 0;
}
