#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
vector<pair<int, int> > G[1 << 20];
int iter[1 << 20];
pair<int, int> e[N];
bool evis[N];
int n;
vector<int> ans;
void addEdge(int u, int v, int id) {
  G[u].push_back(pair<int, int>(v, id));
  G[v].push_back(pair<int, int>(u, id));
}
void dfs(int u, int bits) {
  for (int& i = iter[u]; i < (int)G[u].size();) {
    const auto& edge = G[u][i++];
    if (evis[edge.second]) continue;
    evis[edge.second] = 1;
    dfs(edge.first, bits);
    if ((e[edge.second].first & bits) == edge.first) {
      ans.push_back(2 * edge.second - 1);
      ans.push_back(2 * edge.second);
    } else {
      ans.push_back(2 * edge.second);
      ans.push_back(2 * edge.second - 1);
    }
  }
}
bool check(int len) {
  int bits = (1 << len) - 1;
  for (int i = 0; i <= bits; i++) G[i].clear(), iter[i] = 0;
  for (int i = 1; i <= n; i++) {
    addEdge(e[i].first & bits, e[i].second & bits, i);
    evis[i] = 0;
  }
  int root = -1;
  for (int i = 0; i <= bits; i++) {
    if (G[i].size() & 1) {
      return false;
    }
    if (G[i].size()) root = i;
  }
  assert(root != -1);
  ans.clear();
  dfs(root, bits);
  if (ans.size() != 2 * n) return false;
  return true;
}
void solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &e[i].first, &e[i].second);
  }
  for (int i = 20; i >= 0; i--) {
    if (check(i)) {
      printf("%d\n", i);
      for (auto u : ans) printf("%d ", u);
      printf("\n");
      return;
    }
  }
  assert(0);
}
int main() {
  solve();
  return 0;
}
