#include <bits/stdc++.h>
int oo[1 + 500000 * 2 + 1 + 500000], oh[1 + 500000 * 2 + 1 + 500000];
int link(int o, int h) {
  static int _ = 1;
  oo[_] = o, oh[_] = h;
  return _++;
}
int dsu[(1 << 20)];
int find(int i) { return dsu[i] < 0 ? i : (dsu[i] = find(dsu[i])); }
int join(int i, int j) {
  i = find(i);
  j = find(j);
  if (i == j) return 0;
  if (dsu[i] > dsu[j])
    dsu[i] = j;
  else {
    if (dsu[i] == dsu[j]) dsu[i]--;
    dsu[j] = i;
  }
  return 1;
}
int ij[500000 + 1];
char used[500000];
int ae[(1 << 20)];
int unlink(int i) {
  int o = ae[i];
  ae[i] = oo[o];
  return o == 0 ? -1 : oh[o];
}
int extend(int p, int j) {
  int h_;
  while ((h_ = unlink(j)) != -1) {
    int h = h_ >> 1;
    if (!used[h]) {
      used[h] = 1;
      p = oo[p] = link(0, h_);
      j ^= ij[h];
    }
  }
  return p;
}
int main() {
  static int uu[500000], vv[500000], dd[(1 << 20)];
  int n, m, h, i, j, b, p, p_;
  scanf("%d", &m);
  for (h = 0; h < m; h++) scanf("%d%d", &uu[h], &vv[h]);
  for (b = 0; b < 20; b++) {
    int c;
    n = 1 << b + 1;
    memset(dsu, -1, n * sizeof *dsu);
    memset(dd, 0, n * sizeof *dd);
    c = n;
    for (h = 0; h < m; h++) {
      i = uu[h] & n - 1, j = vv[h] & n - 1;
      dd[i]++, dd[j]++;
      if (join(i, j)) c--;
    }
    for (i = 0; i < n; i++) {
      if (dd[i] % 2 == 1) goto out;
      if (dd[i] == 0) c--;
    }
    if (c > 1) break;
  }
out:
  n = 1 << b;
  for (h = 0; h < m; h++) {
    i = uu[h] & n - 1, j = vv[h] & n - 1;
    ij[h] = i ^ j;
    ae[i] = link(ae[i], h << 1), ae[j] = link(ae[j], h << 1 | 1);
  }
  i = 0;
  while (dd[i] == 0) i++;
  ij[m] = -1 ^ i;
  p_ = link(0, m << 1);
  extend(p_, i);
  for (p = p_, j = -1; p; p = oo[p]) {
    int h_ = oh[p], q = oo[p];
    oo[extend(p, j ^= ij[h_ >> 1])] = q;
  }
  printf("%d\n", b);
  for (p = oo[p_]; p; p = oo[p]) {
    int h_ = oh[p];
    printf("%d %d ", h_ + 1, (h_ ^ 1) + 1);
  }
  printf("\n");
  return 0;
}
