#include <bits/stdc++.h>
using namespace std;
using big = long long;
const int N = 502000;
int n;
int a[N * 2];
int IDX;
int ans[N * 2];
vector<pair<int, int>> adj[(1 << 20) + 1];
bool used[N * 2];
int deg[1 << 20];
inline int id(int x, int y) { return x * 2 - 1 + y; }
void dfs(int x, vector<int> &path, int prev = 0) {
  while (adj[x].size()) {
    auto v = adj[x].back();
    adj[x].pop_back();
    if (!used[std::abs(v.second)]) {
      used[std::abs(v.second)] = true;
      dfs(v.first, path, v.second);
    }
  }
  if (prev != 0) {
    path.push_back(prev);
  }
}
bool ck(int x, bool output) {
  int mask = (1 << x) - 1;
  for (int i = 0; i <= mask; ++i) {
    deg[i] = 0;
  }
  for (int i = 1; i <= n; ++i) {
    if (output) {
      adj[a[id(i, 0)] & mask].emplace_back(a[id(i, 1)] & mask, i);
      adj[a[id(i, 1)] & mask].emplace_back(a[id(i, 0)] & mask, -i);
      used[i] = false;
    }
    ++deg[a[id(i, 0)] & mask];
    ++deg[a[id(i, 1)] & mask];
  }
  for (int i = 0; i <= mask; ++i) {
    if (deg[i] & 1) {
      return false;
    }
  }
  for (int i = 0; i <= mask; ++i) {
    adj[i].clear();
  }
  for (int i = 1; i <= n; ++i) {
    adj[a[id(i, 0)] & mask].emplace_back(a[id(i, 1)] & mask, i);
    adj[a[id(i, 1)] & mask].emplace_back(a[id(i, 0)] & mask, -i);
    used[i] = false;
  }
  vector<int> path;
  for (int i = 0; i <= mask; ++i) {
    if (adj[i].size()) {
      dfs(i, path);
      break;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (!used[i]) {
      return false;
    }
  }
  int top = 0;
  for (int e : path) {
    if (e < 0) {
      ans[++top] = id(-e, 0);
      ans[++top] = id(-e, 1);
    } else {
      ans[++top] = id(e, 1);
      ans[++top] = id(e, 0);
    }
  }
  return true;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i * 2 - 1] >> a[i * 2];
  }
  int l = 0, r = 20;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (ck(mid, false)) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  cout << r << "\n";
  for (int i = 1; i <= n * 2; ++i) {
    cout << ans[i] << " ";
  }
}
