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 double eps = 1e-8;
const double PI = acos(-1.);
const long long MOD = 1000000007;
vector<pair<int, int> > gao(int *x, int n, int *X, int *use, int &U, int &len) {
  int i, j, k;
  for (i = 0; i < n; i++) X[i] = x[i];
  int mx = *max_element(X, X + n);
  len = 0;
  while ((1LL << len) <= mx) len++;
  vector<pair<int, int> > ret;
  for (j = k = 0; k < len; k++) {
    int tmp = -1;
    for (i = j; i < n; i++)
      if (X[i] >> k & 1) {
        tmp = i;
        break;
      }
    use[k] = -1;
    if (tmp == -1) continue;
    if (tmp != j) {
      ret.push_back(make_pair(j, tmp));
      X[j] ^= X[tmp];
      ret.push_back(make_pair(tmp, j));
      X[tmp] ^= X[j];
      ret.push_back(make_pair(j, tmp));
      X[j] ^= X[tmp];
    }
    for (i = 0; i < n; i++)
      if (i != j)
        if (X[i] >> k & 1) {
          ret.push_back(make_pair(i, j));
          X[i] ^= X[j];
        }
    use[k] = j++;
  }
  U = j;
  return ret;
}
int x[10005], X[10005];
int y[10005], Y[10005];
int useX[66], useY[66];
int UX, UY, lenX, lenY;
int main() {
  int i, j, k, T;
  int n, U, len;
  while (~scanf("%d", &n)) {
    for (i = 0; i < n; i++) scanf("%d", &x[i]);
    for (i = 0; i < n; i++) scanf("%d", &y[i]);
    memset(useX, -1, sizeof useX);
    memset(useY, -1, sizeof useY);
    vector<pair<int, int> > px = gao(x, n, X, useX, UX, lenX);
    vector<pair<int, int> > py = gao(y, n, Y, useY, UY, lenY);
    map<int, int> mx, my;
    for (i = 0; i < lenY; i++)
      if (~useY[i]) my[useY[i]] = i;
    for (i = 0; i < lenX; i++)
      if (~useX[i]) mx[useX[i]] = i;
    int fail = 0;
    for (i = 0; i < lenY; i++)
      if (~useY[i])
        if (useX[i] == -1) fail = 1;
    for (i = 0; i < lenX; i++)
      if (~useX[i]) {
        if (useY[i] == -1) {
          int id = useX[i];
          for (j = 0; j < UY; j++)
            if (Y[j] >> i & 1) {
              int t = my[j];
              int s = useX[t];
              px.push_back(make_pair(s, id));
              X[s] ^= X[id];
            }
          px.push_back(make_pair(id, id));
          X[id] ^= X[id];
          useX[i] = -1;
        }
      }
    vector<int> tx, ty;
    for (i = 0; i < UX; i++)
      if (X[i]) tx.push_back(X[i]);
    for (i = 0; i < UY; i++)
      if (Y[i]) ty.push_back(Y[i]);
    sort(tx.begin(), tx.end());
    sort(ty.begin(), ty.end());
    if (tx.size() != ty.size())
      fail = 1;
    else {
      for (i = 0; i < tx.size(); i++)
        if (tx[i] != ty[i]) fail = 1;
    }
    for (i = 0; i < UY; i++) {
      for (j = i; j < UX; j++)
        if (X[j] == Y[i]) break;
      if (i != j) {
        px.push_back(make_pair(i, j));
        X[i] ^= X[j];
        px.push_back(make_pair(j, i));
        X[j] ^= X[i];
        px.push_back(make_pair(i, j));
        X[i] ^= X[j];
      }
    }
    for (i = py.size() - 1; i >= 0; i--) {
      int u = py[i].first;
      int v = py[i].second;
      px.push_back(make_pair(u, v));
      X[u] ^= X[v];
    }
    for (i = 0; i < n; i++)
      if (X[i] != y[i]) fail = 1;
    if (fail)
      printf("-1\n");
    else {
      printf("%d\n", px.size());
      for (i = 0; i < px.size(); i++)
        printf("%d %d\n", px[i].first + 1, px[i].second + 1);
    }
  }
  return 0;
}