#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
using namespace std;
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}
const int N = (1 << 20) + 1;
vector<pair<int, int>> eulerWalk(vector<vector<pair<int, int>>>& gr, int nedges,
                                 int src = 0) {
  int n = ((int)(gr.size()));
  static vector<int> D(N), its(N), eu(N);
  D.clear(), D.resize(n);
  its.clear(), its.resize(n);
  eu.clear(), eu.resize(nedges);
  vector<pair<int, int>> s;
  s = {make_pair(src, -1)};
  static vector<pair<int, int>> ret;
  ret.clear();
  D[src]++;
  while (!s.empty()) {
    auto x = s.back();
    int y, e, &it = its[x.first], end = ((int)(gr[x.first].size()));
    if (it == end) {
      ret.push_back(x);
      s.pop_back();
      continue;
    }
    tie(y, e) = gr[x.first][it++];
    if (!eu[e]) {
      D[x.first]--, D[y]++;
      eu[e] = 1;
      s.emplace_back(y, e);
    }
  }
  for (int x : D)
    if (x < 0 || ((int)(ret.size())) != nedges + 1) return {};
  return {ret.rbegin(), ret.rend()};
}
vector<vector<pair<int, int>>> graph(N);
vector<pair<int, int>> cycle;
bool valid(int k, const vector<pair<int, int>>& pearls) {
  graph.clear();
  graph.resize((1 << k));
  int src;
  for (int i = 0; i < ((int)(pearls.size())); ++i) {
    int u = (pearls[i].first & ((1 << k) - 1));
    int v = (pearls[i].second & ((1 << k) - 1));
    graph[u].emplace_back(v, i);
    graph[v].emplace_back(u, i);
    src = u;
  }
  cycle = eulerWalk(graph, pearls.size(), src);
  return !cycle.empty() && cycle.back().first == src;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> pearls(n);
  for (auto& p : pearls) {
    cin >> p.first >> p.second;
  }
  int res = 20;
  while (!valid(res, pearls)) {
    --res;
  }
  cout << res << '\n';
  for (int i = 0; i < n; ++i) {
    int u = (pearls[i].first & ((1 << res) - 1));
    int v = (pearls[i].second & ((1 << res) - 1));
    pearls[i] = make_pair(u, v);
  }
  for (int i = 1; i <= n; ++i) {
    auto curr = cycle[i];
    int prev_node = cycle[i - 1].first;
    int curr_edge = curr.second;
    if (pearls[curr_edge].first == prev_node &&
        pearls[curr_edge].second == curr.first) {
      cout << 2 * curr_edge + 1 << " " << 2 * curr_edge + 2 << " ";
    } else {
      cout << 2 * curr_edge + 2 << " " << 2 * curr_edge + 1 << " ";
    }
  }
  cout << '\n';
  return 0;
}
