#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const long long MOD1 = 2286661337;
const long long MOD2 = 998244353;
const int INF = (int)1e9 + 7;
const double EPS = 1e-7;
const int N = (int)5e5;
const int A = (int)(1 << 20);
struct edge {
  int to, dir, num;
  edge(int to = 0, int dir = 0, int num = 0) : to(to), dir(dir), num(num) {}
};
int n, ans, cnt, sz;
pair<int, int> a[N];
vector<edge> G[A];
bool used[N], in_cur[A];
vector<pair<int, int> > res;
void build() {
  sz = (1 << cnt);
  for (int i = 0; i < n; ++i) {
    G[a[i].first & sz - 1].push_back(edge(a[i].second & sz - 1, 0, i));
    G[a[i].second & sz - 1].push_back(edge(a[i].first & sz - 1, 1, i));
    in_cur[a[i].first & sz - 1] = in_cur[a[i].second & sz - 1] = true;
  }
}
void clear() {
  for (int i = 0; i < sz; ++i) {
    G[i].clear();
    in_cur[i] = false;
  }
}
void check_dfs(int v) {
  if (!in_cur[v]) {
    return;
  }
  in_cur[v] = false;
  for (edge e : G[v]) {
    check_dfs(e.to);
  }
}
bool check() {
  build();
  bool f = true;
  for (int i = 0; i < sz; ++i) {
    if (G[i].size() & 1) {
      f = false;
      break;
    }
  }
  if (f) {
    for (int i = 0; i < sz; ++i) {
      if (in_cur[i]) {
        check_dfs(i);
        break;
      }
    }
    for (int i = 0; i < sz; ++i) {
      if (in_cur[i]) {
        f = false;
        break;
      }
    }
  }
  clear();
  return f;
}
void dfs(int v) {
  while (G[v].size()) {
    edge cur = G[v].back();
    G[v].pop_back();
    if (used[cur.num]) {
      continue;
    }
    used[cur.num] = true;
    dfs(cur.to);
    res.push_back(make_pair(cur.num * 2, cur.num * 2 + 1));
    if (!cur.dir) {
      swap(res.back().first, res.back().second);
    }
  }
}
void make_cycle() {
  build();
  for (int i = 0; i < sz; ++i) {
    dfs(i);
  }
}
signed main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].first, &a[i].second);
  }
  for (cnt = 20; cnt >= 0; --cnt) {
    if (check()) {
      ans = cnt;
      break;
    }
  }
  make_cycle();
  printf("%d\n", ans);
  for (pair<int, int> elem : res) {
    printf("%d %d ", elem.first + 1, elem.second + 1);
  }
  return 0;
}
