#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
vector<int> g[N];
vector<int> path;
vector<pair<int, int> > E;
void addEdge(int u, int v) {
  g[u].emplace_back((int)E.size());
  E.emplace_back(v, 0);
  g[v].emplace_back((int)E.size());
  E.emplace_back(u, 0);
}
void work(int S) {
  if (g[S].empty()) return;
  stack<int> st;
  st.push(g[S].back() ^ 1);
  while (st.size()) {
    int i = st.top();
    int u = E[i].first;
    for (; g[u].size() && E[g[u].back()].second; g[u].pop_back())
      ;
    if (g[u].size()) {
      int j = g[u].back();
      st.push(j);
      E[j].second = 1;
      j ^= 1;
      E[j].second = 1;
      continue;
    }
    path.emplace_back(i);
    st.pop();
  }
}
unordered_map<int, vector<int> > mp[N];
int a[N];
int t[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int R = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i << 1];
    cin >> a[i << 1 | 1];
  }
  for (int b = 1; b <= 20; R = b++) {
    E.clear();
    for (int i = 0; i < N; ++i) g[i].clear();
    for (int i = 0; i < n + n; i += 2) {
      int u = (((1 << b) - 1) & a[i]);
      int v = (((1 << b) - 1) & a[i + 1]);
      addEdge(u, v);
    }
    bool have_sol = 1;
    for (int i = 0; i < N; ++i)
      if (g[i].size() & 1) {
        have_sol = 0;
        break;
      }
    if (!have_sol) break;
    for (int i = 0; i < N; ++i)
      if (g[i].size()) {
        path.clear();
        work(i);
        have_sol = ((int)path.size() == n + 1);
        break;
      }
    if (!have_sol) break;
  }
  E.clear();
  for (int i = 0; i < N; ++i) g[i].clear();
  for (int i = 0; i < n + n; i += 2) {
    int u = (((1 << R) - 1) & a[i]);
    int v = (((1 << R) - 1) & a[i + 1]);
    addEdge(u, v);
  }
  for (int i = 0; i < N; ++i)
    if (g[i].size()) {
      path.clear();
      work(i);
    }
  assert((int)path.size() == n + 1);
  path.pop_back();
  cout << R << "\n";
  for (int x : path) {
    x ^= 1;
    cout << x + 1 << " ";
    x ^= 1;
    cout << x + 1 << " ";
  }
}
