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.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10101;
const int BIT = 30;
int N;
int arr[MAXN], brr[MAXN];
bool isb[MAXN];
vector<pair<int, int> > vans;
void action(int a, int b) {
  arr[b] ^= arr[a];
  vans.push_back(make_pair(b + 1, a + 1));
}
void aswap(int a, int b) {
  if (a == b) return;
  action(a, b);
  action(b, a);
  action(a, b);
}
void fail() {
  cout << -1 << endl;
  exit(0);
}
void calc() {
  int basis[BIT];
  memset((basis), -1, sizeof(basis));
  memset((isb), 0, sizeof(isb));
  for (int i = 0; i < BIT; i++) {
    for (int j = 0; j < N; j++) {
      if (isb[j]) continue;
      if (arr[j] & (1 << i)) {
        basis[i] = j;
        isb[j] = true;
        break;
      }
    }
    if (basis[i] == -1) continue;
    for (int j = 0; j < N; j++) {
      if (j == basis[i]) continue;
      if (arr[j] & (1 << i)) {
        action(basis[i], j);
      }
    }
  }
  bool bused[BIT];
  memset((bused), 0, sizeof(bused));
  for (int i = 0; i < N; i++) {
    int x = brr[i];
    for (int j = 0; j < BIT; j++) {
      if (basis[j] == -1) continue;
      if (x & (1 << j)) {
        x ^= arr[basis[j]];
        if (!bused[j]) {
          bused[j] = true;
        }
      }
    }
    if (x) fail();
  }
  for (int i = 0; i < N; i++) {
    if (arr[i]) continue;
    int x = brr[i];
    for (int j = 0; j < BIT; j++) {
      if (basis[j] == -1) continue;
      if (x & (1 << j)) {
        x ^= arr[basis[j]];
        action(basis[j], i);
      }
    }
  }
  int mat[BIT], mat2[BIT];
  memset((mat), 0, sizeof(mat));
  memset((mat2), 0, sizeof(mat2));
  memset((bused), 0, sizeof(bused));
  for (int i = 0; i < BIT; i++) {
    if (basis[i] == -1) continue;
    mat2[i] = 1 << i;
    int x = brr[basis[i]];
    for (int j = 0; j < BIT; j++) {
      if (basis[j] == -1) continue;
      if (x & (1 << j)) {
        x ^= arr[basis[j]];
        mat[i] ^= 1 << j;
      }
    }
  }
  for (int i = 0; i < BIT; i++) {
    if (basis[i] == -1) continue;
    int pv = -1;
    for (int j = 0; j < BIT; j++) {
      if (basis[j] == -1) continue;
      if (bused[j]) continue;
      if (mat[j] & 1 << i) {
        pv = j;
        bused[j] = true;
        break;
      }
    }
    if (pv == -1) continue;
    swap(bused[i], bused[pv]);
    swap(mat[i], mat[pv]);
    swap(mat2[i], mat2[pv]);
    for (int j = 0; j < BIT; j++) {
      if (basis[j] == -1) continue;
      if (j == i) continue;
      if (mat[j] & 1 << i) {
        mat[j] ^= mat[i];
        mat2[j] ^= mat2[i];
      }
    }
  }
  for (int i = 0; i < BIT; i++) {
    if (basis[i] == -1) continue;
    if (!(mat[i] & 1 << i)) {
      for (int j = 0; j < BIT; j++) {
        if (basis[j] == -1) continue;
        if (j == i) continue;
        if (mat[j] & 1 << i) action(basis[i], basis[j]);
      }
      action(basis[i], basis[i]);
    }
  }
  for (int i = 0; i < BIT; i++) {
    if (basis[i] == -1) continue;
    int pv = -1;
    for (int j = i; j < BIT; j++) {
      if (basis[j] == -1) continue;
      if (mat2[j] & 1 << i) {
        pv = j;
        break;
      }
    }
    swap(mat2[i], mat2[pv]);
    aswap(basis[i], basis[pv]);
    for (int j = 0; j < BIT; j++) {
      if (basis[j] == -1) continue;
      if (j == i) continue;
      if (mat2[j] & 1 << i) {
        mat2[j] ^= mat2[i];
        action(basis[i], basis[j]);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  for (int i = 0; i < N; i++) cin >> arr[i];
  for (int i = 0; i < N; i++) cin >> brr[i];
  calc();
  int A = vans.size();
  cout << A << "\n";
  for (__typeof(vans.begin()) it = vans.begin(); it != vans.end(); it++) {
    cout << it->first << " " << it->second << "\n";
  }
  return 0;
}