#include <bits/stdc++.h>
using namespace std;
const int N = 6e5 + 10;
const int inf = 1e9;
const int mo = 998244353;
int n;
pair<int, int> ab[N];
vector<pair<int, int> > G[2 * N];
bool evis[N * 2], vvis[2 * N];
vector<int> ans;
void build(int cap) {
  for (auto i = (0); i <= (cap); ++i) G[i].clear();
  memset(evis, 0, sizeof(evis));
  memset(vvis, 0, sizeof(vvis));
  for (auto i = (1); i <= (n); ++i) {
    int a = ab[i].first & cap;
    int b = ab[i].second & cap;
    G[a].push_back(make_pair(b, i * 2 - 1));
    G[b].push_back(make_pair(a, i * 2));
  }
}
void dfs(int u) {
  vvis[u] = 1;
  for (auto x : G[u]) {
    if (!vvis[x.first]) dfs(x.first);
  }
}
bool check(int cap) {
  int comp = 0;
  for (auto i = (0); i <= (cap); ++i) {
    if (G[i].size() & 1) return false;
    if (!vvis[i] && G[i].size()) {
      dfs(i);
      comp++;
    }
  }
  return comp == 1;
}
void eluer(int u, int prev = -1) {
  while (G[u].size()) {
    auto e = G[u].back();
    G[u].pop_back();
    if (!evis[(e.second + 1) / 2]) {
      evis[(e.second + 1) / 2] = 1;
      eluer(e.first, e.second);
    }
  }
  if (prev != -1) {
    int a, b;
    if (prev & 1)
      a = prev, b = prev + 1;
    else
      a = prev, b = prev - 1;
    ans.push_back(b);
    ans.push_back(a);
  }
}
int main() {
  cin >> n;
  for (auto i = (1); i <= (n); ++i) scanf("%d %d", &ab[i].first, &ab[i].second);
  for (auto i = (20); i >= (0); --i) {
    int cap = (1 << i) - 1;
    build(cap);
    if (check(cap)) {
      cout << i << endl;
      for (auto j = (0); j <= (cap); ++j) {
        if (G[j].size()) {
          eluer(j);
          break;
        }
      }
      for (auto x : ans) cout << x << " ";
      cout << endl;
      break;
    }
  }
  return 0;
}
