#include <bits/stdc++.h>
using namespace std;
const int siz = 1 << 20;
vector<pair<int, int> > v[siz];
pair<int, int> arr[500007];
int n;
bool vis[siz];
void dfs(int x) {
  vis[x] = true;
  for (int i = 0; i < (int)v[x].size(); i++) {
    if (!vis[v[x][i].first]) dfs(v[x][i].first);
  }
}
bool solve(int mask) {
  mask = (1 << mask) - 1;
  for (int i = 1; i <= n; i++) {
    int x = (arr[i].first & mask);
    int y = (arr[i].second & mask);
    v[x].push_back({y, 2 * i});
    v[y].push_back({x, 2 * i - 1});
  }
  int cnt = 0;
  for (int i = 0; i <= mask; i++) {
    if (v[i].empty()) continue;
    if (v[i].size() % 2) return false;
    if (!vis[i]) {
      dfs(i);
      cnt++;
    }
  }
  return cnt == 1;
}
void clr(int mask) {
  mask = (1 << mask) - 1;
  for (int i = 0; i <= mask; i++) {
    v[i].clear();
    vis[i] = false;
  }
}
void print(int x, int yy = -1) {
  int n = v[x].size();
  while (!v[x].empty()) {
    int y = v[x].back().second;
    int xx = v[x].back().first;
    v[x].pop_back();
    if (!vis[y]) {
      if (y % 2 == 0)
        vis[y - 1] = vis[y] = true;
      else
        vis[y] = vis[y + 1] = true;
      print(xx, y);
    }
  }
  if (yy != -1) {
    if (yy % 2)
      printf("%d %d ", yy, yy + 1);
    else
      printf("%d %d ", yy, yy - 1);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &arr[i].first, &arr[i].second);
  }
  for (int i = 20; i >= 0; i--) {
    if (solve(i)) {
      printf("%d\n", i);
      memset(vis, false, sizeof(vis));
      for (int j = 0; j < siz; j++) {
        if (!v[j].empty()) {
          print(j);
          break;
        }
      }
      printf("\n");
      return 0;
    } else
      clr(i);
  }
  return 0;
}
