#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &n) {
  n = 0;
  T f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (isdigit(c)) n = n * 10 + c - '0', c = getchar();
  n *= f;
}
template <typename T>
void write(T n) {
  if (n < 0) putchar('-'), n = -n;
  if (n > 9) write(n / 10);
  putchar(n % 10 + '0');
}
struct node {
  int x, y;
} a[2000005];
int n, cnt;
int head[2000005], vet[2000005 * 2], Next[2000005 * 2], id[2000005 * 2];
int in[2000005], vis[2000005];
vector<int> ans;
void add(int x, int y, int z) {
  cnt++;
  Next[cnt] = head[x];
  head[x] = cnt;
  vet[cnt] = y;
  id[cnt] = z;
}
void dfs(int x) {
  vis[x] = 1;
  for (int i = head[x]; i; i = Next[i]) {
    int v = vet[i];
    if (!vis[v]) dfs(v);
  }
}
bool check(int S) {
  cnt = 0;
  for (int i = 0; i <= S; i++) head[i] = in[i] = vis[i] = 0;
  for (int i = 1; i <= n; i++) {
    int x = a[i].x & S, y = a[i].y & S;
    add(x, y, i * 2 - 1);
    add(y, x, i * 2 - 2);
    in[x]++, in[y]++;
  }
  int tot = 0;
  for (int i = 0; i <= S; i++) {
    if (in[i] & 1) return false;
    if (!vis[i] && head[i]) dfs(i), tot++;
  }
  return tot == 1;
}
void find(int x, int pre = -1) {
  for (int &i = head[x]; i; i = Next[i]) {
    int v = vet[i], d = id[i];
    if (vis[d / 2]) continue;
    vis[d / 2] = 1;
    find(v, d);
  }
  if (pre == -1) return;
  ans.push_back(pre), ans.push_back(pre ^ 1);
}
void solve(int S) {
  for (int i = 0; i <= n * 2; i++) vis[i] = 0;
  for (int i = 0; i <= S; i++) {
    if (head[i]) {
      find(i, -1);
      break;
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    printf("%d ", ans[i] + 1);
  }
  puts("");
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    read(a[i].x), read(a[i].y);
  }
  for (int i = 20; i >= 0; i--) {
    if (check((1 << i) - 1)) {
      cout << i << endl;
      solve((1 << i) - 1);
      break;
    }
  }
  return 0;
}
