#include <bits/stdc++.h>
using namespace std;
void solve(vector<vector<pair<long long, pair<long long, long long>>>>& g,
           vector<bool>& del, vector<long long>& st, vector<long long>& ans,
           long long v) {
  for (long long i = st[v]; i < g[v].size(); i++) {
    auto e = g[v][i];
    long long ind = e.second.first / 2;
    if (del[ind]) {
      continue;
    }
    del[ind] = true;
    st[v] = i + 1;
    long long to = e.first;
    solve(g, del, st, ans, to);
    ans.push_back(e.second.second);
    ans.push_back(e.second.first);
    if (st[v] > i + 1) {
      return;
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;
  vector<pair<long long, long long>> e(n);
  for (long long i = 0; i < (long long)(n); ++i) {
    cin >> e[i].first >> e[i].second;
  }
  long long max_k = 0;
  vector<long long> ANS(2 * n);
  for (long long i = 0; i < (long long)(2 * n); ++i) {
    ANS[i] = i;
  }
  for (long long k = 1; k <= 20; k++) {
    vector<vector<pair<long long, pair<long long, long long>>>> g(1 << k);
    vector<long long> st(1 << k);
    vector<bool> del(n);
    for (long long i = 0; i < (long long)(n); ++i) {
      long long x = e[i].first & ((1 << k) - 1);
      long long y = e[i].second & ((1 << k) - 1);
      g[x].push_back({y, {2 * i, 2 * i + 1}});
      g[y].push_back({x, {2 * i + 1, 2 * i}});
    }
    bool bad = false;
    for (long long i = 0; i < (long long)(1 << k); ++i) {
      if (g[i].size() % 2) {
        bad = true;
        break;
      }
    }
    if (bad) {
      break;
    }
    vector<long long> ans;
    for (long long i = 0; i < (long long)(1 << k); ++i) {
      if (g[i].size()) {
        solve(g, del, st, ans, i);
        break;
      }
    }
    if (ans.size() < 2 * n) {
      break;
    }
    max_k = k;
    ANS = ans;
  }
  cout << max_k << endl;
  for (long long i = 0; i < (long long)(2 * n); ++i) {
    cout << ANS[i] + 1 << " ";
  }
  cout << endl;
}
