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;
vector<pair<int, int> > f, s;
vector<int> a, b;
int n;
void make(vector<pair<int, int> > &v, vector<int> &a, int i, int j) {
  v.push_back(make_pair(i + 1, j + 1));
  a[i] ^= a[j];
}
void gauss(vector<int> &mas, vector<pair<int, int> > &mov) {
  int r = 0;
  for (int bit = 30; bit >= 0; bit--) {
    for (int i = r; i < n; i++) {
      if (mas[i] & (1 << bit)) {
        if (i != r) {
          make(mov, mas, r, i);
          make(mov, mas, i, r);
          make(mov, mas, r, i);
        }
        for (int j = 0; j < n; ++j) {
          if (j == r) continue;
          if (!((mas[j] ^ mas[r]) & (1 << bit))) make(mov, mas, j, r);
        }
        r++;
        break;
      }
    }
  }
}
int gethigh(int val) {
  if (val == 0) return -1;
  int ans = 30;
  while (ans && !(val & (1 << ans))) ans--;
  return ans;
}
void swap(vector<pair<int, int> > &v, vector<int> &a, int i, int j) {
  make(v, a, i, j);
  make(v, a, j, i);
  make(v, a, i, j);
}
int main() {
  scanf("%d", &n);
  a.resize(n), b.resize(n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
  gauss(a, f);
  gauss(b, s);
  int to = min(31, n);
  for (int i = 0; i < to; i++) {
    if (b[i] == 0) {
      make(f, a, i, i);
      continue;
    }
    int bit = gethigh(b[i]);
    if (gethigh(a[i]) != bit) {
      int ind = -1;
      for (int iter = 0; iter < to; ++iter)
        if (gethigh(a[iter]) == bit) ind = iter;
      if (ind == -1) break;
      ::swap(f, a, i, ind);
    }
    for (int j = bit - 1; j >= 0; j--) {
      if ((a[i] ^ b[i]) & (1 << j)) {
        for (int iter = i + 1; iter < to; iter++) {
          int h = gethigh(a[iter]);
          if (h == j) {
            make(f, a, i, iter);
            break;
          }
        }
      }
    }
  }
  for (int i = 0; i < ((int)a.size()); ++i)
    if (a[i] != b[i]) {
      printf("-1\n");
      return 0;
    }
  printf("%d\n", ((int)s.size()) + ((int)f.size()));
  reverse(s.begin(), s.end());
  for (int i = 0; i < ((int)f.size()); ++i)
    printf("%d %d\n", f[i].first, f[i].second);
  for (int i = 0; i < ((int)s.size()); ++i)
    printf("%d %d\n", s[i].first, s[i].second);
  return 0;
}