#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
int n;
int part[N][2];
bool vis[N];
vector<pair<int, int>> g[N];
vector<int> res;
void dfs(int u) {
  vis[u] = true;
  for (auto v : g[u])
    if (!vis[v.first]) dfs(v.first);
}
bool check(int mask) {
  for (int i = 0; i <= mask; ++i) g[i].clear(), vis[i] = false;
  for (int i = 0; i < n; ++i) {
    int u = part[i][0] & mask;
    int v = part[i][1] & mask;
    g[u].push_back({v, 2 * i + 1});
    g[v].push_back({u, 2 * i});
  }
  int c = 0;
  for (int i = 0; i <= mask; ++i)
    if (g[i].size() % 2)
      return false;
    else if (!vis[i] && g[i].size()) {
      ++c;
      dfs(i);
    }
  return c == 1;
}
void construct(int u, int id = -1) {
  while (g[u].size()) {
    auto v = g[u].back();
    g[u].pop_back();
    if (vis[v.second / 2]) continue;
    vis[v.second / 2] = true;
    construct(v.first, v.second);
  }
  if (~id) {
    res.push_back(id);
    res.push_back(id ^ 1);
  }
}
int build(int mask) {
  for (int i = 0; i < n; ++i) vis[i] = false;
  for (int i = 0; 1; ++i)
    if (g[i].size()) {
      construct(i);
      break;
    }
  cout << mask << endl;
  for (auto u : res) cout << u + 1 << " ";
  cout << endl;
  return 0;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> part[i][0] >> part[i][1];
  for (int i = 20; i >= 0; --i)
    if (check((1 << i) - 1)) return build(i);
}
