Problem: Johnny's younger sister Megan had a birthday recently. Her brother has bought her a box signed as "Your beautiful necklace — do it yourself!". It contains many necklace parts and some magic glue. 

The necklace part is a chain connecting two pearls. Color of each pearl can be defined by a non-negative integer. The magic glue allows Megan to merge two pearls (possibly from the same necklace part) into one. The beauty of a connection of pearls in colors u and v is defined as follows: let 2^k be the greatest power of two dividing u ⊕ v — [exclusive or](https://en.wikipedia.org/wiki/Exclusive_or#Computer_science) of u and v. Then the beauty equals k. If u = v, you may assume that beauty is equal to 20.

Each pearl can be combined with another at most once. Merging two parts of a necklace connects them. Using the glue multiple times, Megan can finally build the necklace, which is a cycle made from connected necklace parts (so every pearl in the necklace is combined with precisely one other pearl in it). The beauty of such a necklace is the minimum beauty of a single connection in it. The girl wants to use all available necklace parts to build exactly one necklace consisting of all of them with the largest possible beauty. Help her!

Input

The first line contains n (1 ≤ n ≤ 5 ⋅ 10^5) — the number of necklace parts in the box. Each of the next n lines contains two integers a and b (0 ≤ a, b < 2^{20}), which denote colors of pearls presented in the necklace parts. Pearls in the i-th line have indices 2i - 1 and 2i respectively.

Output

The first line should contain a single integer b denoting the maximum possible beauty of a necklace built from all given parts.

The following line should contain 2n distinct integers p_i (1 ≤ p_i ≤ 2n) — the indices of initial pearls in the order in which they appear on a cycle. Indices of pearls belonging to the same necklace part have to appear at neighboring positions in this permutation (so 1 4 3 2 is not a valid output, whereas 2 1 4 3 and 4 3 1 2 are). If there are many possible answers, you can print any.

Examples

Input


5
13 11
11 1
3 5
17 1
9 27


Output


3
8 7 9 10 5 6 1 2 3 4 


Input


5
13 11
11 1
3 5
17 1
7 29


Output


2
8 7 10 9 5 6 4 3 2 1 


Input


1
1 1


Output


20
2 1 

Note

In the first example the following pairs of pearls are combined: (7, 9), (10, 5), (6, 1), (2, 3) and (4, 8). The beauties of connections equal correspondingly: 3, 3, 3, 20, 20.

The following drawing shows this construction.

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const long long INF = numeric_limits<int>::max();
const long long LINF = numeric_limits<long long>::max();
const long long mod = 1000 * 1000 * 1000 + 7;
vector<vector<pair<int, int> > > g;
vector<int> getC(int ed) {
  vector<int> used(ed, 0);
  vector<pair<int, int> > st;
  vector<int> res;
  int n = g.size();
  int id = 0;
  while (g[id].empty()) ++id;
  st.push_back(pair<int, int>(id, -1));
  res.push_back(id);
  vector<int> cyc;
  vector<int> p(n, 0);
  while (!st.empty()) {
    int v = st.back().first;
    int e = st.back().second;
    int ph = 0;
    for (int i = p[v]; i < g[v].size(); ++i, ++p[v]) {
      int id = g[v][i].second;
      if (used[id]) continue;
      used[id] = 1;
      st.push_back(pair<int, int>(g[v][i].first, id));
      ph = 1;
      break;
    }
    if (ph == 0) {
      cyc.push_back(v);
      st.pop_back();
    }
  }
  map<pair<int, int>, int> mp;
  vector<pair<int, int> > pp;
  for (int i = 0; i + 1 < cyc.size(); ++i) {
    int a = cyc[i], b = cyc[i + 1];
    if (a >= b) swap(a, b);
    pair<int, int> p(a, b);
    if (mp.find(p) == mp.end()) {
      mp[p] = pp.size();
      pp.push_back(p);
    }
  }
  vector<vector<int> > edg(pp.size());
  for (int i = 0; i < g.size(); ++i) {
    for (auto to : g[i]) {
      int a = to.first;
      int b = i;
      if (a >= b) swap(a, b);
      pair<int, int> p(a, b);
      int id = mp[p];
      edg[id].push_back(to.second);
    }
  }
  for (int i = 0; i < edg.size(); ++i) {
    sort(edg[i].begin(), edg[i].end());
  }
  vector<int> str(edg.size(), 0);
  for (int i = 0; i + 1 < cyc.size(); ++i) {
    int a = cyc[i], b = cyc[i + 1];
    if (a >= b) swap(a, b);
    pair<int, int> p(a, b);
    int id = mp[p];
    res.push_back(edg[id][str[id]]);
    str[id] += 2;
  }
  res.resize(ed + 1);
  return res;
}
vector<int> us;
void dfs(int pos) {
  us[pos] = 1;
  for (auto to : g[pos]) {
    if (us[to.first]) continue;
    dfs(to.first);
  }
  return;
}
bool check(vector<int> ans, const vector<int>& a, const vector<int>& b, int M) {
  for (int i = 0; i < ans.size(); ++i) {
    if (ans[i] & 1) {
      ans[i] = a[ans[i] / 2];
    } else {
      ans[i] = b[ans[i] / 2 - 1];
    }
  }
  ans.push_back(ans[0]);
  bool ok = 1;
  for (int i = 1; i + 1 < ans.size(); i += 2) {
    if ((ans[i] & M) != (ans[i + 1] & M)) return 0;
  }
  return 1;
}
void solve() {
  int n;
  cin >> n;
  vector<int> cnt(1 << 20, 0);
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    ++cnt[a[i]];
    ++cnt[b[i]];
  }
  int k = 20;
  while (true) {
    int ok = 1;
    for (int i = 0; i < cnt.size(); ++i) {
      if (cnt[i] & 1) {
        ok = 0;
        break;
      }
    }
    if (ok) {
      int N = 1 << k;
      int M = N - 1;
      g.assign(N, vector<pair<int, int> >());
      for (int i = 0; i < n; ++i) {
        int aa = a[i] & M;
        int bb = b[i] & M;
        g[bb].push_back(pair<int, int>(aa, i));
        g[aa].push_back(pair<int, int>(bb, i));
      }
      int id = 0;
      us.assign(N, 0);
      while (g[id].size() == 0) {
        ++id;
      }
      dfs(id);
      for (int i = 0; i < N; ++i) {
        if ((!g[i].empty()) && (us[i] == 0)) {
          ok = 0;
          break;
        }
      }
      if (ok) break;
    }
    --k;
    int sz = cnt.size() / 2;
    for (int i = 0; i < sz; ++i) {
      cnt[i] += cnt[i + sz];
    }
    cnt.resize(sz);
  }
  cout << k << endl;
  vector<int> cyc = getC(n);
  int lst1 = a[cyc[1]], lst2 = b[cyc[1]];
  vector<int> ans1, ans2;
  int N = 1 << k;
  int M = N - 1;
  for (int i = 1; i <= n; ++i) {
    int id = cyc[i];
    if ((lst1 & M) == (a[id] & M)) {
      ans1.push_back(2 * id + 1);
      ans1.push_back(2 * id + 2);
      lst1 = b[id];
    } else {
      ans1.push_back(2 * id + 2);
      ans1.push_back(2 * id + 1);
      lst1 = a[id];
    }
    if ((lst2 & M) == (a[id] & M)) {
      ans2.push_back(2 * id + 1);
      ans2.push_back(2 * id + 2);
      lst2 = b[id];
    } else {
      ans2.push_back(2 * id + 2);
      ans2.push_back(2 * id + 1);
      lst2 = a[id];
    }
  }
  int ok1 = check(ans1, a, b, M);
  int ok2 = check(ans2, a, b, M);
  if (ok1) {
    for (int i = 0; i < ans1.size(); ++i) {
      cout << ans1[i] << " ";
    }
  } else {
    if (ok2) {
      for (int i = 0; i < ans2.size(); ++i) {
        cout << ans2[i] << " ";
      }
    } else {
      assert(0);
    }
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();
  return 0;
}