#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const int N = 2e6 + 5;
const int oo = 1e9 + 7;
int n;
int idx[N];
vector<pair<int, int> > g[N];
int deg[N];
vector<int> ans;
int mask;
int a[N];
int b[N];
bool vis[N];
void bfs(int u) {
  queue<int> q;
  vis[u] = 1;
  q.push(u);
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (pair<int, int> vi : g[u]) {
      int v = vi.first;
      if (vis[v] == 0) {
        vis[v] = 1;
        q.push(v);
      }
    }
  }
}
bool build(int k) {
  mask = (1 << k) - 1;
  for (int i = 0; i <= mask; i++) {
    g[i].clear();
    vis[i] = deg[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    int u = a[i] & mask;
    int v = b[i] & mask;
    g[u].push_back({v, i * 2});
    g[v].push_back({u, i * 2 + 1});
    deg[u]++;
    deg[v]++;
  }
  for (int i = 0; i <= mask; i++)
    if (deg[i] % 2) return 0;
  for (int i = 0; i <= mask; i++) {
    if (deg[i] > 0) {
      bfs(i);
      break;
    }
  }
  for (int i = 0; i <= mask; i++) {
    if (deg[i] > 0 and vis[i] == 0) return 0;
  }
  return 1;
}
void dfs(int u, int last = -1) {
  while (!g[u].empty()) {
    int v = g[u].back().first;
    int i = g[u].back().second;
    g[u].pop_back();
    if (vis[i / 2]) continue;
    vis[i / 2] = 1;
    dfs(v, i);
  }
  if (last != -1) {
    ans.push_back((last ^ 1) - 1);
    ans.push_back((last)-1);
  }
}
void gens(int k) {
  mask = (1 << k) - 1;
  for (int i = 1; i <= n; i++) vis[i] = 0;
  for (int i = 0; i <= mask; i++) {
    if (deg[i] > 0) {
      dfs(i);
      break;
    }
  }
  assert(ans.size() == n * 2);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
  int lo = 0, hi = 20, mid;
  while (lo < hi) {
    mid = (lo + hi + 1) / 2;
    if (build(mid))
      lo = mid;
    else
      hi = mid - 1;
  }
  build(lo);
  gens(lo);
  cout << lo << "\n";
  for (int i : ans) cout << i << " ";
}
