#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
int n;
int part[N][2];
vector<pair<int, int>> adj[N];
bool visited[N];
void dfs(int u) {
  visited[u] = 1;
  for (auto v : adj[u]) {
    if (visited[v.first]) continue;
    dfs(v.first);
  }
}
bool construct_and_if_euler(int b) {
  int mask = (1 << b) - 1;
  for (int i = 0; i <= mask; i++) {
    adj[i].clear();
    visited[i] = false;
  }
  for (int i = 1; i <= n; i++) {
    int u = part[i][0] & mask;
    int v = part[i][1] & mask;
    adj[u].push_back({v, 2 * i - 1});
    adj[v].push_back({u, 2 * i - 2});
  }
  int comp = 0;
  for (int i = 0; i <= mask; i++) {
    if (adj[i].size() % 2) {
      return false;
    }
    if (!visited[i] && adj[i].size() > 0) {
      comp++;
      dfs(i);
    }
  }
  return comp == 1;
}
vector<int> ans;
void go(int u, int prev) {
  while (adj[u].size()) {
    auto v = adj[u].back();
    adj[u].pop_back();
    int ind = v.second;
    if (visited[ind / 2]) continue;
    visited[ind / 2] = 1;
    go(v.first, ind);
  }
  if (prev != -1) {
    ans.push_back(prev);
    ans.push_back(prev ^ 1);
  }
}
void traverse(int b) {
  int mask = (1 << b) - 1;
  for (int i = 0; i <= n; i++) {
    visited[i] = false;
  }
  for (int i = 0; i <= mask; i++) {
    if (adj[i].size() > 0) {
      go(i, -1);
      break;
    }
  }
  for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i] + 1 << " ";
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int u, v;
    cin >> u >> v;
    part[i][0] = u;
    part[i][1] = v;
  }
  for (int at_least_b = 20; at_least_b >= 0; at_least_b--) {
    if (construct_and_if_euler(at_least_b)) {
      cout << at_least_b << endl;
      traverse(at_least_b);
      break;
    }
  }
  return 0;
}
