#include <bits/stdc++.h>
using namespace std;
const int N = 500001;
int n, vis[2 * N];
vector<int> a, tour, v[1 << 20];
void dfs(int x, vector<int> &a) {
  int y = x ^ 1;
  vis[x] = vis[y] = 1;
  while (v[a[y]].size()) {
    int c = v[a[y]].back();
    v[a[y]].pop_back();
    if (vis[c]) continue;
    dfs(c, a);
  }
  tour.push_back(y);
  tour.push_back(x);
}
vector<int> calc(vector<int> &a) {
  tour.clear();
  for (int i = 0; i < 2 * n; i++) {
    vis[i] = 0;
  }
  for (int i = 0; i < 2 * n; i++) {
    v[a[i]].push_back(i);
  }
  dfs(0, a);
  for (auto &i : a) v[i].clear();
  if ((int)tour.size() != 2 * n) return {};
  for (int i = 1; i < 2 * n; i += 2) {
    if (a[tour[i]] != a[tour[(i + 1) % (2 * n)]]) {
      return {};
    }
  }
  return tour;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  a.resize(2 * n);
  for (auto &i : a) cin >> i;
  int res = 20;
  for (int ans = 1; ans <= 21; ans++) {
    vector<int> b;
    for (auto &i : a) {
      b.push_back(i & ((1 << ans) - 1));
    }
    auto cur = calc(b);
    if (cur.size() == 0) {
      res = ans - 1;
      break;
    }
  }
  for (auto &i : a) {
    i &= ((1 << res) - 1);
  }
  auto cur = calc(a);
  cout << res << endl;
  for (auto &i : cur) cout << i + 1 << " ";
  cout << endl;
}
