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];
int real_arr[MAXN];
bool isb[MAXN], risb[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];
  int rbasis[BIT];
  memset((bused), 0, sizeof(bused));
  memset((risb), 0, sizeof(risb));
  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 (!risb[i]) {
            rbasis[j] = i;
            risb[i] = 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);
      }
    }
  }
  if (0) {
    cout << "B ";
    for (int i = 0; i < BIT; i++) cout << basis[i] << " ";
    cout << endl;
    cout << "-A ";
    for (int i = 0; i < N; i++) cout << arr[i] << " ";
    cout << endl;
  }
  int mat[BIT], mat2[BIT];
  bool oked[BIT];
  memset((mat), 0, sizeof(mat));
  memset((mat2), 0, sizeof(mat2));
  memset((oked), 0, sizeof(oked));
  memset((rbasis), -1, sizeof(rbasis));
  memset((bused), 0, sizeof(bused));
  for (int i = 0; i < BIT; i++) {
    if (basis[i] == -1) continue;
    mat2[i] = 1 << i;
    rbasis[i] = 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;
      }
    }
  }
  if (0)
    for (int i = 0; i < BIT; i++) {
      if (basis[i] == -1) continue;
      for (int j = 0; j < BIT; j++) {
        if (basis[j] == -1) continue;
        cout << !!(mat[i] & (1 << j)) << " ";
      }
      cout << endl;
    }
  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]);
      }
    }
  }
  if (0)
    for (int i = 0; i < BIT; i++) {
      if (basis[i] == -1) continue;
      for (int j = 0; j < BIT; j++) {
        if (basis[j] == -1) continue;
        cout << !!(mat[i] & (1 << j)) << " ";
      }
      cout << endl;
    }
  return;
  for (int i = 0; i < BIT; i++) {
    if (basis[i] == -1) continue;
    int pv = -1;
    int ii = rbasis[i];
    for (int j = 0; j < BIT; j++) {
      if (basis[j] == -1) continue;
      if (oked[j]) continue;
      if (mat[j] & (1 << i)) {
        pv = j;
        break;
      }
    }
    if (pv == -1) {
      continue;
    }
    if (0) cout << "II " << ii << " PV " << pv << endl;
    oked[pv] = true;
    swap(mat2[ii], mat2[pv]);
    int lb = -1;
    for (int j = 0; j < BIT; j++)
      if (basis[j] != -1 && rbasis[j] == pv) lb = j;
    swap(rbasis[i], rbasis[lb]);
    if (0) cout << "SWAP RB " << i << " " << lb << endl;
    aswap(basis[ii], basis[pv]);
    vector<pair<int, int> > vb;
    int b = basis[pv];
    int orig_arr = arr[b];
    for (int j = 0; j < BIT; j++) {
      if (basis[j] == -1) continue;
      if (j == i) continue;
      if (1) {
        int rj = rbasis[j];
        if ((mat2[pv] ^ mat[pv]) & (1 << j)) {
          mat2[pv] ^= mat2[rj];
          arr[basis[pv]] ^= arr[basis[rj]];
          vb.push_back(make_pair(basis[pv] + 1, basis[rj] + 1));
        }
      }
    }
    if (!(mat2[pv] & (1 << i))) {
      mat2[pv] ^= 1 << i;
      arr[b] ^= orig_arr;
      vans.push_back(make_pair(b + 1, b + 1));
    }
    for (__typeof(vb.begin()) it = vb.begin(); it != vb.end(); it++)
      vans.push_back(*it);
  }
  vector<pair<int, int> > vi;
  for (int q = 0; q < BIT; q++) {
    int i = rbasis[q];
    if (i == -1 || basis[i] == -1) continue;
    if (oked[i]) continue;
    vi.push_back(make_pair(basis[q] + 1, basis[q] + 1));
    for (int j = 0; j < BIT; j++) {
      if (basis[j] == -1) continue;
      if (j == q) continue;
      if ((mat2[i] ^ mat[i]) & (1 << j)) {
        mat2[i] ^= 1 << j;
        vi.push_back(make_pair(basis[q] + 1, basis[j] + 1));
        cout << "VIPB " << q << " " << j << endl;
        cout << "NOW " << rbasis[q] << endl;
      }
    }
  }
  if (0)
    for (int i = 0; i < BIT; i++) {
      if (basis[i] == -1) continue;
      for (int j = 0; j < BIT; j++) {
        if (basis[j] == -1) continue;
        cout << !!(mat2[i] & (1 << j)) << " ";
      }
      cout << endl;
    }
  if (0) {
    cout << "A ";
    for (int i = 0; i < N; i++) cout << arr[i] << " ";
    cout << endl;
  }
}
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];
  for (int i = 0; i < N; i++) real_arr[i] = arr[i];
  calc();
  for (__typeof(vans.begin()) it = vans.begin(); it != vans.end(); it++) {
    real_arr[it->first - 1] ^= real_arr[it->second - 1];
  }
  if (0) {
    cout << "R ";
    for (int i = 0; i < N; i++) cout << real_arr[i] << " ";
    cout << endl;
  }
  int A = vans.size();
  cout << A << "\n";
  for (__typeof(vans.begin()) it = vans.begin(); it != vans.end(); it++) {
    cout << it->first << " " << it->second << "\n";
  }
  cout << flush;
  for (int i = 0; i < N; i++) assert(real_arr[i] == brr[i]);
  return 0;
}