#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e6 + 5;
bool visited[MAXN];
vector<pair<int, int>> v1[MAXN];
int st;
int n;
int ord[MAXN];
int a[MAXN];
int b[MAXN];
int hold;
int sz;
void dfs(int curr, int par) {
  while (!v1[curr].empty()) {
    int ind = v1[curr].back().second;
    int val = v1[curr].back().first;
    v1[curr].pop_back();
    if (visited[ind]) {
      continue;
    }
    visited[ind] = true;
    dfs(val, curr);
    ord[sz++] = ind;
  }
}
bool check(int curr) {
  hold = curr;
  int m = (1 << curr);
  for (int i = 0; i < m; i++) {
    v1[i].clear();
  }
  for (int i = 0; i <= n; i++) {
    visited[i] = false;
  }
  for (int i = 1; i <= n; i++) {
    int u = a[i] & (m - 1);
    int v = b[i] & (m - 1);
    v1[u].push_back(make_pair(v, i));
    v1[v].push_back(make_pair(u, i));
  }
  for (int i = 0; i < m; i++) {
    if (v1[i].size() % 2) {
      return false;
    }
  }
  for (int i = 0; i < m; i++) {
    sz = 0;
    if (v1[i].size()) {
      st = i;
      dfs(i, i);
      st = i;
      if (sz != n) {
        return false;
      } else {
        return true;
      }
    }
  }
  return true;
}
void printans(int k) {
  cout << k << "\n";
  for (int i = 0; i < n; i++) {
    if ((a[ord[i]] & ((1 << k) - 1)) == st) {
      cout << 2 * ord[i] - 1 << " " << 2 * ord[i] << " ";
      st = b[ord[i]] & ((1 << k) - 1);
    } else {
      cout << 2 * ord[i] << " " << 2 * ord[i] - 1 << " ";
      st = a[ord[i]] & ((1 << k) - 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
  }
  int ans = 0;
  for (int b = 20; b >= 0; b--) {
    if (check(b)) {
      ans = b;
      break;
    }
  }
  printans(ans);
}
