#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
class DSU {
 public:
  vector<int> arr;
  DSU(int sz) : arr(sz) {
    for (int i = 0; i < sz; i++) arr[i] = i;
  }
  int find(int p) {
    if (p != arr[p]) arr[p] = find(arr[p]);
    return arr[p];
  }
  void join(int a, int b) { arr[find(a)] = find(b); }
};
bool ok(const vector<pii>& parts, int pow) {
  int nv = 1 << pow, mask = nv - 1;
  vector<int> deg(nv);
  DSU dsu(nv);
  for (auto p : parts) {
    int a = p.first & mask, b = p.second & mask;
    deg[a]++, deg[b]++;
    dsu.join(a, b);
  }
  int id = -1;
  for (int i = 0; i < nv; i++) {
    if (deg[i] == 0) continue;
    if (deg[i] % 2 == 1) return false;
    if (id == -1)
      id = dsu.find(i);
    else if (dsu.find(i) != id)
      return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pii> parts(n);
  for (auto& p : parts) cin >> p.first >> p.second;
  for (int pow = 20; pow >= 0; pow--) {
    if (!ok(parts, pow)) continue;
    cout << pow << '\n';
    const int nv = 1 << pow, mask = nv - 1;
    vector<vector<int>> adj(nv);
    for (int i = 0; i < n; i++) {
      adj[parts[i].first & mask].push_back(i);
      adj[parts[i].second & mask].push_back(i);
    }
    vector<int> res;
    vector<bool> edge_used(n);
    stack<pii> s;
    s.push({parts[0].first & mask, -1});
    while (!s.empty()) {
      auto [cur, eid] = s.top();
      if (adj[cur].empty()) {
        s.pop();
        if (eid == -1) continue;
        int vert = parts[eid].first & mask;
        if (vert == cur) {
          res.push_back(2 * eid + 1);
          res.push_back(2 * eid + 2);
        } else {
          res.push_back(2 * eid + 2);
          res.push_back(2 * eid + 1);
        }
        continue;
      }
      int n_eid = adj[cur].back();
      adj[cur].pop_back();
      if (edge_used[n_eid]) continue;
      edge_used[n_eid] = true;
      int nxt = parts[n_eid].first ^ parts[n_eid].second ^ cur;
      s.push({nxt & mask, n_eid});
    }
    for (int r : res) cout << r << ' ';
    return 0;
  }
}
