#include <bits/stdc++.h>
using namespace std;
const int L = 20, N = 1 << L;
int n, k, ALL, deg[N];
vector<int> adj[N];
struct edge {
  int x, y;
  int i, j;
  bool dead;
  void rev() {
    swap(x, y);
    swap(i, j);
  }
  void add_edge(int idx) {
    adj[x & ALL].push_back(idx);
    deg[x & ALL]++;
  }
};
vector<edge> e;
int sz_tour, tour[N];
void dfs(int u, int p = -1) {
  while (!adj[u].empty()) {
    auto idx = adj[u].back();
    adj[u].pop_back();
    if (e[idx].dead) continue;
    e[idx].dead = e[idx ^ 1].dead = true;
    int v = e[idx].y & ALL;
    dfs(v, idx);
  }
  tour[sz_tour++] = p;
}
void clean() {
  for (int i = 0; i < (int)(2 * n); i++) {
    e[i].dead = false;
    int u = e[i].x & ALL;
    if (!adj[u].empty()) adj[u].clear();
    deg[u] = 0;
  }
  sz_tour = 0;
}
bool good(int k) {
  ::k = k;
  ALL = (1 << k) - 1;
  for (int i = 0; i < (int)(2 * n); i++) e[i].add_edge(i);
  bool ok = true;
  for (int i = 0; i < (int)(ALL + 1); i++) ok &= deg[i] % 2 == 0;
  if (!ok) return false;
  dfs(e[0].x & ALL);
  if (sz_tour - 1 == n) {
    assert(tour[sz_tour - 1] == -1);
    sz_tour--;
    reverse(tour, tour + sz_tour);
    return true;
  }
  return false;
}
vector<int> ans;
int solve() {
  cin >> n;
  e.resize(2 * n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> e[i + i].x >> e[i + i].y;
    e[i + i].i = 2 * i + 1;
    e[i + i].j = 2 * i + 2;
    e[i + i + 1] = e[i + i];
    e[i + i + 1].rev();
  }
  int lo = 0, hi = 21;
  while (lo + 1 < hi) {
    int mi = (lo + hi) / 2;
    if (good(mi))
      lo = mi;
    else
      hi = mi;
    clean();
  }
  good(lo);
  for (int i = 0; i < (int)(sz_tour); i++) {
    int idx = tour[i];
    ans.push_back(e[idx].i);
    ans.push_back(e[idx].j);
  }
  return lo;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << solve() << endl;
  for (auto x : ans) cout << x << ' ';
  return 0;
}
