#include <bits/stdc++.h>
#pragma GCC optimize(2)
const double esp = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int inf = 1e9;
using namespace std;
long long read() {
  char ch = getchar();
  long long x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 2e6 + 10;
int n;
pair<int, int> col[N];
vector<pair<int, int> > vec[N];
int vis[N];
vector<int> ans;
void dfs(int u, int id) {
  while (vec[u].size()) {
    pair<int, int> top = vec[u].back();
    vec[u].pop_back();
    if (!vis[top.second]) {
      vis[top.second] = 1;
      dfs(top.first, top.second);
    }
  }
  if (id != -1) ans.push_back(id);
}
bool check(int mask) {
  ans.clear();
  int t = mask - 1;
  for (int i = 0; i <= n + t; i++) vec[i].clear();
  for (int i = 1; i <= n; i++) {
    vis[(i - 1) << 1] = 0;
    vis[(i - 1) << 1 | 1] = 0;
    vec[col[i].first & t].push_back(make_pair(t + i, (i - 1) << 1));
    vec[t + i].push_back(make_pair(col[i].first & t, (i - 1) << 1));
    vec[col[i].second & t].push_back(make_pair(t + i, (i - 1) << 1 | 1));
    vec[t + i].push_back(make_pair(col[i].second & t, (i - 1) << 1 | 1));
  }
  for (int i = 0; i <= t + n; i++) {
    if (vec[i].size() & 1) {
      return 0;
    }
  }
  for (int i = 0; i <= t + n; i++) {
    if (vec[i].size()) {
      dfs(i, -1);
      break;
    }
  }
  if (ans.size() != 2 * n) {
    return 0;
  }
  return 1;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    col[i].first = read();
    col[i].second = read();
  }
  for (int i = 20; i >= 0; i--) {
    if (check(1 << i)) {
      printf("%d\n", i);
      for (auto k : ans) {
        printf("%d ", k + 1);
      }
      break;
    }
  }
  return 0;
}
