#include <bits/stdc++.h>
using namespace std;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
const int N = (1LL << 19) + 10;
int n, a[N], b[N], u[N], v[N];
vector<int> eu, eu2, adj[2 * N];
bool vis[N];
void dfs(int x, int c, int j) {
  bool b1 = (c == a[j]);
  int xx = (b1 ? v[j] : u[j]);
  while (!adj[xx].empty()) {
    int i = adj[xx].back();
    adj[xx].pop_back();
    if (!vis[i]) {
      vis[i] = true;
      int y = (v[i] == xx ? v[i] : u[i]);
      int d = (v[i] == xx ? b[i] : a[i]);
      dfs(y, d, i);
    }
  }
  eu.push_back(2 * j + b1 + 1);
  eu.push_back(2 * j + !b1 + 1);
}
void solve(int ans) {
  cout << ans << '\n';
  for (int x : eu2) {
    cout << x << ' ';
  }
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = (0); i < (n); i++) {
    cin >> a[i] >> b[i];
  }
  for (int l = (0); l < (21); l++) {
    for (int i = (0); i < (2 * N); i++) {
      adj[i].clear();
    }
    fill(vis, vis + n, false);
    for (int i = (0); i < (n); i++) {
      u[i] = (a[i] & ((1LL << l) - 1));
      v[i] = (b[i] & ((1LL << l) - 1));
      adj[u[i]].push_back(i);
      adj[v[i]].push_back(i);
    }
    for (int i = (0); i < (2 * N); i++) {
      if (((int)(adj[i]).size()) % 2 == 1) {
        solve(l - 1);
        return 0;
      }
    }
    eu.clear();
    vis[0] = true;
    dfs(u[0], a[0], 0);
    if (((int)(eu).size()) != 2 * n) {
      solve(l - 1);
      return 0;
    }
    eu2.clear();
    eu2.assign((eu).begin(), (eu).end());
  }
  solve(20);
}
