#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n;
int a[20000], b[20000];
pair<int, int> op[2000000];
int opi;
pair<int, int> op2[2000000];
int op2i;
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) scanf("%d", &b[i]);
  int done = -1;
  for (i = 0; i < 31; i++) {
    int now;
    for (j = done + 1; j < n; j++) {
      if (a[j] & (1 << i)) break;
    }
    if (j == n) continue;
    now = j;
    if (now != done + 1) {
      swap(a[now], a[done + 1]);
      op[opi++] = pair<int, int>(now, done + 1);
      op[opi++] = pair<int, int>(done + 1, now);
      op[opi++] = pair<int, int>(now, done + 1);
    }
    for (j = done + 2; j < n; j++) {
      if (a[j] & (1 << i)) {
        a[j] ^= a[done + 1];
        op[opi++] = pair<int, int>(j, done + 1);
      }
    }
    done++;
  }
  for (i = done; i >= 0; i--) {
    int lsb;
    for (j = 0; j < 31; j++) {
      if ((1 << j) & a[i]) {
        lsb = j;
        break;
      }
    }
    for (j = i - 1; j >= 0; j--) {
      if (a[j] & (1 << lsb)) {
        a[j] ^= a[i];
        op[opi++] = pair<int, int>(j, i);
      }
    }
  }
  int done2 = -1;
  for (i = 0; i < 31; i++) {
    int now;
    for (j = done2 + 1; j < n; j++) {
      if (b[j] & (1 << i)) break;
    }
    if (j == n) continue;
    now = j;
    if (now != done2 + 1) {
      swap(b[now], b[done2 + 1]);
      op2[op2i++] = pair<int, int>(now, done2 + 1);
      op2[op2i++] = pair<int, int>(done2 + 1, now);
      op2[op2i++] = pair<int, int>(now, done2 + 1);
    }
    for (j = done2 + 2; j < n; j++) {
      if (b[j] & (1 << i)) {
        b[j] ^= b[done2 + 1];
        op2[op2i++] = pair<int, int>(j, done2 + 1);
      }
    }
    done2++;
  }
  for (i = done2; i >= 0; i--) {
    int lsb;
    for (j = 0; j < 31; j++) {
      if ((1 << j) & b[i]) {
        lsb = j;
        break;
      }
    }
    for (j = i - 1; j >= 0; j--) {
      if (b[j] & (1 << lsb)) {
        b[j] ^= b[i];
        op2[op2i++] = pair<int, int>(j, i);
      }
    }
  }
  if (done < done2) {
    printf("-1");
    return 0;
  }
  for (i = 0; i <= done; i++) {
    int lsb;
    for (j = 0; j < 31; j++) {
      if ((1 << j) & a[i]) {
        lsb = j;
        break;
      }
    }
    for (j = 0; j <= done; j++) {
      if (i == j) continue;
      if ((1 << lsb) & b[j]) {
        a[j] ^= a[i];
        op[opi++] = pair<int, int>(j, i);
      }
    }
    if (!(b[i] & (1 << lsb))) {
      a[i] ^= a[i];
      op[opi++] = pair<int, int>(i, i);
    }
  }
  for (i = 0; i <= done; i++) {
    if (a[i] != b[i]) {
      printf("-1");
      return 0;
    }
  }
  printf("%d\n", opi + op2i);
  for (i = 0; i < opi; i++)
    printf("%d %d\n", op[i].first + 1, op[i].second + 1);
  for (i = op2i - 1; i >= 0; i--)
    printf("%d %d\n", op2[i].first + 1, op2[i].second + 1);
  return 0;
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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>
#pragma warning(disable : 4996)
using namespace std;
int n;
int a[20000], b[20000];
pair<int, int> op[2000000];
int opi;
pair<int, int> op2[2000000];
int op2i;
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) scanf("%d", &b[i]);
  int done = -1;
  for (i = 0; i < 31; i++) {
    int now;
    for (j = done + 1; j < n; j++) {
      if (a[j] & (1 << i)) break;
    }
    if (j == n) continue;
    now = j;
    if (now != done + 1) {
      swap(a[now], a[done + 1]);
      op[opi++] = pair<int, int>(now, done + 1);
      op[opi++] = pair<int, int>(done + 1, now);
      op[opi++] = pair<int, int>(now, done + 1);
    }
    for (j = done + 2; j < n; j++) {
      if (a[j] & (1 << i)) {
        a[j] ^= a[done + 1];
        op[opi++] = pair<int, int>(j, done + 1);
      }
    }
    done++;
  }
  for (i = done; i >= 0; i--) {
    int lsb;
    for (j = 0; j < 31; j++) {
      if ((1 << j) & a[i]) {
        lsb = j;
        break;
      }
    }
    for (j = i - 1; j >= 0; j--) {
      if (a[j] & (1 << lsb)) {
        a[j] ^= a[i];
        op[opi++] = pair<int, int>(j, i);
      }
    }
  }
  int done2 = -1;
  for (i = 0; i < 31; i++) {
    int now;
    for (j = done2 + 1; j < n; j++) {
      if (b[j] & (1 << i)) break;
    }
    if (j == n) continue;
    now = j;
    if (now != done2 + 1) {
      swap(b[now], b[done2 + 1]);
      op2[op2i++] = pair<int, int>(now, done2 + 1);
      op2[op2i++] = pair<int, int>(done2 + 1, now);
      op2[op2i++] = pair<int, int>(now, done2 + 1);
    }
    for (j = done2 + 2; j < n; j++) {
      if (b[j] & (1 << i)) {
        b[j] ^= b[done2 + 1];
        op2[op2i++] = pair<int, int>(j, done2 + 1);
      }
    }
    done2++;
  }
  for (i = done2; i >= 0; i--) {
    int lsb;
    for (j = 0; j < 31; j++) {
      if ((1 << j) & b[i]) {
        lsb = j;
        break;
      }
    }
    for (j = i - 1; j >= 0; j--) {
      if (b[j] & (1 << lsb)) {
        b[j] ^= b[i];
        op2[op2i++] = pair<int, int>(j, i);
      }
    }
  }
  if (done < done2) {
    printf("-1");
    return 0;
  }
  for (i = 0; i <= done; i++) {
    int lsb;
    for (j = 0; j < 31; j++) {
      if ((1 << j) & a[i]) {
        lsb = j;
        break;
      }
    }
    for (j = 0; j <= done; j++) {
      if (i == j) continue;
      if ((1 << lsb) & b[j]) {
        a[j] ^= a[i];
        op[opi++] = pair<int, int>(j, i);
      }
    }
    if (!(b[i] & (1 << lsb))) {
      a[i] ^= a[i];
      op[opi++] = pair<int, int>(i, i);
    }
  }
  for (i = 0; i <= done; i++) {
    if (a[i] != b[i]) {
      printf("-1");
      return 0;
    }
  }
  printf("%d\n", opi + op2i);
  for (i = 0; i < opi; i++)
    printf("%d %d\n", op[i].first + 1, op[i].second + 1);
  for (i = op2i - 1; i >= 0; i--)
    printf("%d %d\n", op2[i].first + 1, op2[i].second + 1);
  return 0;
}

```