#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
const int maxn = 2e6 + 5;
int n, a[maxn], ansBeauty;
vector<int> finalTour;
bool find(int beauty) {
  int addend = (1 << beauty) - 1;
  vector<set<pair<int, pair<int, int> > > > graph(addend + 1);
  for (int i = 1; i <= n; i++) {
    int x = (a[i] & addend);
    int y = (a[i + 1] & addend);
    graph[x].insert({y, {i, i + 1}});
    graph[y].insert({x, {i + 1, i}});
    i++;
  }
  stack<pair<int, int> > s;
  for (int i = 0; i < addend + 1; ++i) {
    if (graph[i].size() % 2) return 0;
    if (s.empty() and !graph[i].empty()) s.push({-1, i});
  }
  vector<int> tour;
  while (!s.empty()) {
    int groupid = s.top().second;
    int index = s.top().first;
    if (graph[groupid].empty()) {
      s.pop();
      if (index != -1) {
        tour.emplace_back(index);
        if (index % 2)
          index++;
        else
          index--;
        tour.emplace_back(index);
      }
    } else {
      auto it = ((graph[groupid]).begin());
      int to = (*it).first;
      auto temp = (*it).second;
      graph[groupid].erase(it);
      graph[to].erase({groupid, {temp.second, temp.first}});
      s.push({temp.second, to});
    }
  }
  if (tour.size() != n) return 0;
  ansBeauty = beauty;
  finalTour = tour;
  return 1;
}
int32_t main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[2 * i - 1], &a[2 * i]);
  }
  n += n;
  int l = 0, r = 20;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (find(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%d\n", ansBeauty);
  for (const auto &it : finalTour) printf("%d ", it);
  printf("\n");
  return 0;
}
