#include <bits/stdc++.h>
using namespace std;
template <typename T>
void get_int(T &x) {
  char t = getchar();
  bool neg = false;
  x = 0;
  for (; (t > '9' || t < '0') && t != '-'; t = getchar())
    ;
  if (t == '-') neg = true, t = getchar();
  for (; t <= '9' && t >= '0'; t = getchar()) x = x * 10 + t - '0';
  if (neg) x = -x;
}
template <typename T>
void print_int(T x) {
  if (x < 0) putchar('-'), x = -x;
  short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
const int inf = 0x3f3f3f3f;
const long long Linf = 1ll << 61;
const double pi = acos(-1.0);
int n, x[10111], y[10111], bx[30], by[30], xcnt, ycnt;
int tmp[10111], ord[10111];
bool okx[32], oky[32];
int getbase(int t[], int b[]) {
  for (int i = 0; i < n; i++) {
    tmp[i] = t[i];
    ord[i] = i;
  }
  int cnt = 0;
  for (int i = 0; i < 30; i++) {
    int id = -1;
    for (int j = cnt; j < n && id == -1; j++)
      if ((tmp[j] >> i) & 1) id = j;
    if (id == -1) continue;
    swap(tmp[cnt], tmp[id]);
    swap(ord[cnt], ord[id]);
    b[cnt] = ord[cnt];
    for (int j = 0; j < n; j++)
      if (j != cnt && (tmp[j] >> i) & 1) tmp[j] ^= tmp[cnt];
    cnt++;
  }
  return cnt;
}
bool sol[30];
int mat[35][35];
bool find_sol(int base[], int bcnt, int tar) {
  memset(mat, 0, sizeof(mat));
  for (int i = 0; i < 30; i++)
    for (int j = 0; j < bcnt; j++) mat[i][j] = (base[j] >> i) & 1;
  for (int i = 0; i < 30; i++) sol[i] = (tar >> i) & 1;
  for (int i = 0; i < 30; i++) {
    if (mat[i][i] == 0) {
      int id = -1;
      for (int j = i; j < 30 && id == -1; j++)
        if (mat[j][i]) id = j;
      if (id == -1) continue;
      for (int j = 0; j < 30; j++) swap(mat[i][j], mat[id][j]);
      swap(sol[i], sol[id]);
    }
    for (int j = 0; j < 30; j++) {
      if (i != j && mat[j][i]) {
        for (int k = 0; k < 30; k++) mat[j][k] ^= mat[i][k];
        sol[j] ^= sol[i];
      }
    }
  }
  for (int i = 0; i < bcnt; i++)
    if (sol[i]) tar ^= base[i];
  if (tar) return false;
  return true;
}
vector<pair<int, int> > op1, op2;
int main() {
  get_int(n);
  for (int i = 0; i < n; i++) get_int(x[i]);
  for (int i = 0; i < n; i++) get_int(y[i]);
  xcnt = getbase(x, bx);
  ycnt = getbase(y, by);
  sort(bx, bx + xcnt);
  sort(by, by + ycnt);
  for (int i = 0; i < xcnt; i++) {
    if (i != bx[i]) {
      op1.push_back(make_pair(i, bx[i]));
      op1.push_back(make_pair(bx[i], i));
      op1.push_back(make_pair(i, bx[i]));
      swap(x[i], x[bx[i]]);
    }
  }
  for (int i = 0; i < ycnt; i++) {
    if (i != by[i]) {
      op2.push_back(make_pair(i, by[i]));
      op2.push_back(make_pair(by[i], i));
      op2.push_back(make_pair(i, by[i]));
      swap(y[i], y[by[i]]);
    }
  }
  for (int i = 0; i < ycnt; i++) {
    if (!find_sol(x, xcnt, y[i])) {
      puts("-1");
      return 0;
    }
    if (i >= xcnt) {
      op1.push_back(make_pair(i, i));
      x[i] = 0;
      for (int j = 0; j < xcnt; j++)
        if (sol[j]) {
          op1.push_back(make_pair(i, j));
          x[i] ^= x[j];
        }
    } else {
      for (int j = i; j < xcnt; j++)
        if (sol[j]) {
          if (i != j) {
            op1.push_back(make_pair(i, j));
            op1.push_back(make_pair(j, i));
            op1.push_back(make_pair(i, j));
            swap(x[i], x[j]);
          }
          for (int j2 = 0; j2 < xcnt; j2++)
            if (sol[j2] && j != j2) {
              op1.push_back(make_pair(i, j2));
              x[i] ^= x[j2];
            }
          break;
        }
    }
  }
  for (int i = ycnt; i < n; i++) {
    op1.push_back(make_pair(i, i));
    x[i] = 0;
    find_sol(x, ycnt, y[i]);
    for (int j = 0; j < ycnt; j++)
      if (sol[j]) {
        op1.push_back(make_pair(i, j));
        x[i] ^= x[j];
      }
  }
  printf("%d\n", (int)op1.size() + (int)op2.size());
  for (int i = 0; i < (int)op1.size(); i++)
    printf("%d %d\n", op1[i].first + 1, op1[i].second + 1);
  for (int i = (int)op2.size() - 1; i >= 0; i--) {
    x[op2[i].first] ^= x[op2[i].second];
    printf("%d %d\n", op2[i].first + 1, op2[i].second + 1);
  }
  return 0;
}

### Prompt

Generate a Cpp solution to the following problem:

There are some tasks which have the following structure: you are given a model, and you can do some operations, you should use these operations to achive the goal. One way to create a new task is to use the same model and same operations, but change the goal.

Let's have a try. I have created the following task for Topcoder SRM 557 Div1-Hard: you are given n integers x1, x2, ..., xn. You are allowed to perform the assignments (as many as you want) of the following form xi ^= xj (in the original task i and j must be different, but in this task we allow i to equal j). The goal is to maximize the sum of all xi.

Now we just change the goal. You are also given n integers y1, y2, ..., yn. You should make x1, x2, ..., xn exactly equal to y1, y2, ..., yn. In other words, for each i number xi should be equal to yi.

Input

The first line contains an integer n (1 ≤ n ≤ 10000). The second line contains n integers: x1 to xn (0 ≤ xi ≤ 109). The third line contains n integers: y1 to yn (0 ≤ yi ≤ 109).

Output

If there is no solution, output -1.

If there is a solution, then in the first line output an integer m (0 ≤ m ≤ 1000000) – the number of assignments you need to perform. Then print m lines, each line should contain two integers i and j (1 ≤ i, j ≤ n), which denote assignment xi ^= xj.

If there are multiple solutions you can print any of them. We can prove that under these constraints if there exists a solution then there always exists a solution with no more than 106 operations.

Examples

Input

2
3 5
6 0


Output

2
1 2
2 2


Input

5
0 0 0 0 0
1 2 3 4 5


Output

-1


Input

3
4 5 6
1 2 3


Output

5
3 1
1 2
2 2
2 3
3 1


Input

3
1 2 3
4 5 6


Output

-1

Note

Assignment a ^= b denotes assignment a = a ^ b, where operation "^" is bitwise XOR of two integers.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void get_int(T &x) {
  char t = getchar();
  bool neg = false;
  x = 0;
  for (; (t > '9' || t < '0') && t != '-'; t = getchar())
    ;
  if (t == '-') neg = true, t = getchar();
  for (; t <= '9' && t >= '0'; t = getchar()) x = x * 10 + t - '0';
  if (neg) x = -x;
}
template <typename T>
void print_int(T x) {
  if (x < 0) putchar('-'), x = -x;
  short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
const int inf = 0x3f3f3f3f;
const long long Linf = 1ll << 61;
const double pi = acos(-1.0);
int n, x[10111], y[10111], bx[30], by[30], xcnt, ycnt;
int tmp[10111], ord[10111];
bool okx[32], oky[32];
int getbase(int t[], int b[]) {
  for (int i = 0; i < n; i++) {
    tmp[i] = t[i];
    ord[i] = i;
  }
  int cnt = 0;
  for (int i = 0; i < 30; i++) {
    int id = -1;
    for (int j = cnt; j < n && id == -1; j++)
      if ((tmp[j] >> i) & 1) id = j;
    if (id == -1) continue;
    swap(tmp[cnt], tmp[id]);
    swap(ord[cnt], ord[id]);
    b[cnt] = ord[cnt];
    for (int j = 0; j < n; j++)
      if (j != cnt && (tmp[j] >> i) & 1) tmp[j] ^= tmp[cnt];
    cnt++;
  }
  return cnt;
}
bool sol[30];
int mat[35][35];
bool find_sol(int base[], int bcnt, int tar) {
  memset(mat, 0, sizeof(mat));
  for (int i = 0; i < 30; i++)
    for (int j = 0; j < bcnt; j++) mat[i][j] = (base[j] >> i) & 1;
  for (int i = 0; i < 30; i++) sol[i] = (tar >> i) & 1;
  for (int i = 0; i < 30; i++) {
    if (mat[i][i] == 0) {
      int id = -1;
      for (int j = i; j < 30 && id == -1; j++)
        if (mat[j][i]) id = j;
      if (id == -1) continue;
      for (int j = 0; j < 30; j++) swap(mat[i][j], mat[id][j]);
      swap(sol[i], sol[id]);
    }
    for (int j = 0; j < 30; j++) {
      if (i != j && mat[j][i]) {
        for (int k = 0; k < 30; k++) mat[j][k] ^= mat[i][k];
        sol[j] ^= sol[i];
      }
    }
  }
  for (int i = 0; i < bcnt; i++)
    if (sol[i]) tar ^= base[i];
  if (tar) return false;
  return true;
}
vector<pair<int, int> > op1, op2;
int main() {
  get_int(n);
  for (int i = 0; i < n; i++) get_int(x[i]);
  for (int i = 0; i < n; i++) get_int(y[i]);
  xcnt = getbase(x, bx);
  ycnt = getbase(y, by);
  sort(bx, bx + xcnt);
  sort(by, by + ycnt);
  for (int i = 0; i < xcnt; i++) {
    if (i != bx[i]) {
      op1.push_back(make_pair(i, bx[i]));
      op1.push_back(make_pair(bx[i], i));
      op1.push_back(make_pair(i, bx[i]));
      swap(x[i], x[bx[i]]);
    }
  }
  for (int i = 0; i < ycnt; i++) {
    if (i != by[i]) {
      op2.push_back(make_pair(i, by[i]));
      op2.push_back(make_pair(by[i], i));
      op2.push_back(make_pair(i, by[i]));
      swap(y[i], y[by[i]]);
    }
  }
  for (int i = 0; i < ycnt; i++) {
    if (!find_sol(x, xcnt, y[i])) {
      puts("-1");
      return 0;
    }
    if (i >= xcnt) {
      op1.push_back(make_pair(i, i));
      x[i] = 0;
      for (int j = 0; j < xcnt; j++)
        if (sol[j]) {
          op1.push_back(make_pair(i, j));
          x[i] ^= x[j];
        }
    } else {
      for (int j = i; j < xcnt; j++)
        if (sol[j]) {
          if (i != j) {
            op1.push_back(make_pair(i, j));
            op1.push_back(make_pair(j, i));
            op1.push_back(make_pair(i, j));
            swap(x[i], x[j]);
          }
          for (int j2 = 0; j2 < xcnt; j2++)
            if (sol[j2] && j != j2) {
              op1.push_back(make_pair(i, j2));
              x[i] ^= x[j2];
            }
          break;
        }
    }
  }
  for (int i = ycnt; i < n; i++) {
    op1.push_back(make_pair(i, i));
    x[i] = 0;
    find_sol(x, ycnt, y[i]);
    for (int j = 0; j < ycnt; j++)
      if (sol[j]) {
        op1.push_back(make_pair(i, j));
        x[i] ^= x[j];
      }
  }
  printf("%d\n", (int)op1.size() + (int)op2.size());
  for (int i = 0; i < (int)op1.size(); i++)
    printf("%d %d\n", op1[i].first + 1, op1[i].second + 1);
  for (int i = (int)op2.size() - 1; i >= 0; i--) {
    x[op2[i].first] ^= x[op2[i].second];
    printf("%d %d\n", op2[i].first + 1, op2[i].second + 1);
  }
  return 0;
}

```