#include <bits/stdc++.h>
using namespace std;
long long v[51], d[51], A[51], a[21000], b[21000];
int va[51], vb[51], pos[21000], nps[21000], x[51], ans1[2100000], ans2[2100000],
    da, db, n, tot, m;
bool t[21000];
bool gauss(long long a) {
  if (tot > 32) cout << "hehe" << endl;
  for (int i = 0; i <= 32; ++i) {
    A[i] = (a & d[i]) > 0;
    for (int j = 1; j <= tot; ++j)
      if (v[j] & d[i]) A[i] |= d[j];
  }
  for (int i = 0; i < tot; ++i) {
    int j = i;
    while ((A[j] & d[i + 1]) == 0) {
      ++j;
      if (j > 32) {
        cout << "woca" << endl;
      }
    }
    swap(A[i], A[j]);
    for (int j = 0; j <= 32; ++j)
      if (i != j && (A[j] & d[i + 1])) A[j] ^= A[i];
  }
  for (int i = 0; i < tot; ++i) x[i + 1] = A[i] & 1;
  for (int i = 1; i <= tot; ++i)
    if (x[i]) a ^= v[i];
  return !a;
}
int aim() {
  for (int i = 1; i <= da; ++i)
    if (x[i] && t[i]) return i;
  return 0;
}
bool trb() {
  tot = 0;
  for (int i = 1; i <= da; ++i) v[++tot] = a[va[i]];
  memset(t, 1, sizeof(t));
  memset(pos, 0, sizeof(pos));
  memset(nps, 0, sizeof(nps));
  for (int i = 1; i <= db; ++i)
    if (gauss(b[vb[i]])) {
      int k = aim();
      for (int j = 1; j <= da; ++j)
        if (j != k && x[j]) ans1[++m] = va[k], ans2[m] = va[j];
      t[k] = 0;
      pos[vb[i]] = va[k];
      nps[va[k]] = vb[i];
      a[va[k]] = b[vb[i]];
      tot = 0;
      for (int j = 1; j <= da; ++j) v[++tot] = a[va[j]];
    } else
      return 0;
  for (int i = 1; i <= db; ++i) {
    if (pos[vb[i]] == vb[i]) continue;
    ans1[++m] = vb[i];
    ans2[m] = pos[vb[i]];
    ans1[++m] = pos[vb[i]];
    ans2[m] = vb[i];
    ans1[++m] = vb[i];
    ans2[m] = pos[vb[i]];
    int aa = vb[i], bb = nps[vb[i]];
    swap(pos[aa], pos[bb]);
    nps[pos[aa]] = aa;
    nps[pos[bb]] = bb;
  }
  memset(t, 0, sizeof(t));
  tot = 0;
  for (int i = 1; i <= db; ++i) t[vb[i]] = 1, v[++tot] = b[vb[i]];
  return 1;
}
int main() {
  d[0] = 1;
  for (int i = 1; i <= 32; ++i) d[i] = d[i - 1] << 1;
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; ++i) scanf("%I64d", &a[i]);
    for (int i = 1; i <= n; ++i) scanf("%I64d", &b[i]);
    tot = 0;
    da = 0;
    for (int i = 1; i <= n; ++i)
      if (!gauss(a[i]) && a[i]) va[++da] = i, v[++tot] = a[i];
    tot = 0;
    db = 0;
    for (int i = 1; i <= n; ++i)
      if (!gauss(b[i]) && b[i]) vb[++db] = i, v[++tot] = b[i];
    m = 0;
    if (!trb()) {
      printf("-1\n");
      continue;
    }
    for (int i = 1; i <= n; ++i)
      if (!t[i]) {
        gauss(b[i]);
        ans1[++m] = i;
        ans2[m] = i;
        for (int j = 1; j <= db; ++j)
          if (x[j]) ans1[++m] = i, ans2[m] = vb[j];
      }
    printf("%d\n", m);
    for (int i = 1; i <= m; ++i) printf("%d %d\n", ans1[i], ans2[i]);
  }
  return 0;
}

### Prompt

Your challenge is to write 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;
long long v[51], d[51], A[51], a[21000], b[21000];
int va[51], vb[51], pos[21000], nps[21000], x[51], ans1[2100000], ans2[2100000],
    da, db, n, tot, m;
bool t[21000];
bool gauss(long long a) {
  if (tot > 32) cout << "hehe" << endl;
  for (int i = 0; i <= 32; ++i) {
    A[i] = (a & d[i]) > 0;
    for (int j = 1; j <= tot; ++j)
      if (v[j] & d[i]) A[i] |= d[j];
  }
  for (int i = 0; i < tot; ++i) {
    int j = i;
    while ((A[j] & d[i + 1]) == 0) {
      ++j;
      if (j > 32) {
        cout << "woca" << endl;
      }
    }
    swap(A[i], A[j]);
    for (int j = 0; j <= 32; ++j)
      if (i != j && (A[j] & d[i + 1])) A[j] ^= A[i];
  }
  for (int i = 0; i < tot; ++i) x[i + 1] = A[i] & 1;
  for (int i = 1; i <= tot; ++i)
    if (x[i]) a ^= v[i];
  return !a;
}
int aim() {
  for (int i = 1; i <= da; ++i)
    if (x[i] && t[i]) return i;
  return 0;
}
bool trb() {
  tot = 0;
  for (int i = 1; i <= da; ++i) v[++tot] = a[va[i]];
  memset(t, 1, sizeof(t));
  memset(pos, 0, sizeof(pos));
  memset(nps, 0, sizeof(nps));
  for (int i = 1; i <= db; ++i)
    if (gauss(b[vb[i]])) {
      int k = aim();
      for (int j = 1; j <= da; ++j)
        if (j != k && x[j]) ans1[++m] = va[k], ans2[m] = va[j];
      t[k] = 0;
      pos[vb[i]] = va[k];
      nps[va[k]] = vb[i];
      a[va[k]] = b[vb[i]];
      tot = 0;
      for (int j = 1; j <= da; ++j) v[++tot] = a[va[j]];
    } else
      return 0;
  for (int i = 1; i <= db; ++i) {
    if (pos[vb[i]] == vb[i]) continue;
    ans1[++m] = vb[i];
    ans2[m] = pos[vb[i]];
    ans1[++m] = pos[vb[i]];
    ans2[m] = vb[i];
    ans1[++m] = vb[i];
    ans2[m] = pos[vb[i]];
    int aa = vb[i], bb = nps[vb[i]];
    swap(pos[aa], pos[bb]);
    nps[pos[aa]] = aa;
    nps[pos[bb]] = bb;
  }
  memset(t, 0, sizeof(t));
  tot = 0;
  for (int i = 1; i <= db; ++i) t[vb[i]] = 1, v[++tot] = b[vb[i]];
  return 1;
}
int main() {
  d[0] = 1;
  for (int i = 1; i <= 32; ++i) d[i] = d[i - 1] << 1;
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; ++i) scanf("%I64d", &a[i]);
    for (int i = 1; i <= n; ++i) scanf("%I64d", &b[i]);
    tot = 0;
    da = 0;
    for (int i = 1; i <= n; ++i)
      if (!gauss(a[i]) && a[i]) va[++da] = i, v[++tot] = a[i];
    tot = 0;
    db = 0;
    for (int i = 1; i <= n; ++i)
      if (!gauss(b[i]) && b[i]) vb[++db] = i, v[++tot] = b[i];
    m = 0;
    if (!trb()) {
      printf("-1\n");
      continue;
    }
    for (int i = 1; i <= n; ++i)
      if (!t[i]) {
        gauss(b[i]);
        ans1[++m] = i;
        ans2[m] = i;
        for (int j = 1; j <= db; ++j)
          if (x[j]) ans1[++m] = i, ans2[m] = vb[j];
      }
    printf("%d\n", m);
    for (int i = 1; i <= m; ++i) printf("%d %d\n", ans1[i], ans2[i]);
  }
  return 0;
}

```