#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long INFll = 1LL << 62;
struct edge {
  int u, ind;
  int b, e;
};
const int MAXN = 1 << 20;
struct eulerian {
  vector<vector<edge>> edges;
  vector<int> ind, used;
  int n, m;
  eulerian(int n, int m) : n(n), m(m) {
    edges = vector<vector<edge>>(n, vector<edge>());
    ind = vector<int>(n, 0);
    used = vector<int>(m, 0);
  }
  vector<pair<int, int>> euler;
  void dfs_euler(int v, edge *pe = 0) {
    for (; ind[v] < edges[v].size(); ind[v]++) {
      edge &e = edges[v][ind[v]];
      if (!used[e.ind]) {
        used[e.ind] = 1;
        dfs_euler(e.u, &e);
      }
    }
    if (pe) euler.push_back({pe->e, pe->b});
  }
  bool euler_path() {
    int r = -1;
    for (int i = 0; i < n; i++)
      if (edges[i].size() & 1)
        return 0;
      else if (edges[i].size())
        r = i;
    dfs_euler(r);
    return euler.size() == m;
  }
};
int main() {
  int n;
  scanf(" %d ", &n);
  int a[n], b[n];
  for (int i = 0; i < n; i++) scanf(" %d %d ", a + i, b + i);
  for (int s = 20; s >= 0; s--) {
    eulerian eu(1 << s, n);
    for (int i = 0; i < n; i++) {
      eu.edges[a[i] & ((1 << s) - 1)].push_back(
          {b[i] & ((1 << s) - 1), i, 2 * i + 1, 2 * i + 2});
      eu.edges[b[i] & ((1 << s) - 1)].push_back(
          {a[i] & ((1 << s) - 1), i, 2 * i + 2, 2 * i + 1});
    }
    if (eu.euler_path()) {
      cout << s << "\n";
      for (auto p : eu.euler) cout << p.first << " " << p.second << " ";
      cout << "\n";
      return 0;
    }
  }
}
