#include <bits/stdc++.h>
using namespace std;
int n, a[500005], b[500005];
vector<pair<int, pair<int, int> > > nei[1 << 20];
vector<int> reg[1 << 20];
vector<bool> ban[1 << 20];
int now[1 << 20];
vector<int> pa;
void dfs(int x = a[1]) {
  for (int &i = now[x]; i < nei[x].size(); i++)
    if (!ban[x][i]) {
      int y = nei[x][i].first, y1 = nei[x][i].second.first,
          y2 = nei[x][i].second.second;
      ban[x][i] = ban[y][reg[x][i]] = true;
      dfs(y);
      pa.push_back(y2);
      pa.push_back(y1);
    }
}
void sol(int x) {
  int i;
  for (i = 1; i <= n; i++) {
    a[i] %= 1 << x;
    b[i] %= 1 << x;
  }
  for (i = 0; i < 1 << x; i++) {
    nei[i].clear();
    reg[i].clear();
    ban[i].clear();
  }
  for (i = 1; i <= n; i++) {
    if (a[i] == b[i]) {
      nei[a[i]].push_back(make_pair(a[i], make_pair(2 * i - 1, 2 * i)));
      nei[a[i]].push_back(make_pair(a[i], make_pair(2 * i, 2 * i - 1)));
      reg[a[i]].push_back(nei[a[i]].size() - 1);
      reg[a[i]].push_back(nei[a[i]].size() - 2);
    } else {
      nei[a[i]].push_back(make_pair(b[i], make_pair(2 * i - 1, 2 * i)));
      nei[b[i]].push_back(make_pair(a[i], make_pair(2 * i, 2 * i - 1)));
      reg[a[i]].push_back(nei[b[i]].size() - 1);
      reg[b[i]].push_back(nei[a[i]].size() - 1);
    }
    ban[a[i]].push_back(false);
    ban[b[i]].push_back(false);
  }
  for (i = 0; i < 1 << x; i++)
    if (nei[i].size() % 2) return;
  memset(now, 0, sizeof(now));
  pa.clear();
  dfs();
  if (pa.size() != 2 * n) return;
  cout << x << endl;
  for (i = 2 * n - 1; ~i; i--) cout << pa[i] << " ";
  exit(0);
}
int main() {
  int i;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%d%d", a + i, b + i);
  for (i = 20;; i--) sol(i);
  return 0;
}
