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;
int n;
int x[211111], y[211111];
int num[211111];
int sz;
vector<pair<int, int> > ans;
int b[55];
int cont[55][55];
int nn[55][55];
int did[55];
int mem[55][55];
void go(int i, int j) {
  ans.push_back(make_pair(i + 1, j + 1));
  x[i] ^= x[j];
}
int a[55][55];
int B[55];
int need[55];
int r[55];
void gau() {
  for (int i = 0; i < sz; i++)
    for (int j = 0; j < sz; j++) a[i][j] = cont[j][i];
  for (int i = 0; i < sz; i++) B[i] = need[i];
  int s = 0;
  for (int i = 0; i < sz; i++) {
    int f = -1;
    for (int j = s; j < sz; j++)
      if (a[j][i] == 1) {
        f = j;
        break;
      }
    if (f == -1) {
      continue;
    }
    if (f != s) {
      for (int j = 0; j < sz; j++) swap(a[f][j], a[s][j]);
      swap(B[f], B[s]);
    }
    for (int j = 0; j < sz; j++)
      if (j != s && a[j][i] == 1) {
        for (int k = 0; k < sz; k++) a[j][k] ^= a[s][k];
        B[j] ^= B[s];
      }
    s++;
  }
  for (int i = 0; i < sz; i++) r[i] = 0;
  for (int i = 0; i < sz; i++)
    for (int j = 0; j < sz; j++)
      if (a[i][j] == 1 && B[i] == 1) r[j] = 1;
}
void build(int f, int z) {
  if (z) {
    for (int i = 0; i < sz; i++) need[i] = nn[f][i];
    gau();
  }
  if (r[f] == 0) {
    go(f, f);
    for (int j = 0; j < sz; j++) cont[f][j] = 0;
  }
  for (int i = 0; i < sz; i++)
    if (i != f && r[i]) {
      go(f, i);
      for (int j = 0; j < sz; j++) cont[f][j] ^= cont[i][j];
    }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  sz = 0;
  for (int b = 29; b >= 0; b--) {
    int f = -1;
    for (int i = sz; i < n; i++)
      if (x[i] & (1ll << (b))) {
        f = i;
        break;
      }
    if (f == -1) continue;
    if (f != sz) go(sz, f);
    for (int i = 0; i < n; i++)
      if (i != sz && (x[i] & (1ll << (b))) > 0) go(i, sz);
    num[sz] = b;
    sz++;
  }
  for (int i = 0; i < n; i++) scanf("%d", &y[i]);
  int bad = 0;
  for (int i = sz; i < n; i++) {
    int t = y[i];
    for (int j = 0; j < sz; j++)
      if (t & (1ll << (num[j]))) {
        go(i, j);
        t ^= x[j];
      }
    if (t != 0) bad = 1;
  }
  for (int i = 0; i < sz; i++) b[i] = x[i];
  for (int i = 0; i < sz; i++)
    for (int j = 0; j < sz; j++) cont[i][j] = 0;
  for (int i = 0; i < sz; i++) cont[i][i] = 1;
  for (int g = sz - 1; g >= 0; g--) {
    int t = y[g];
    if (t == 0) continue;
    for (int i = 0; i < sz; i++) {
      if (t & (1ll << (num[i]))) {
        nn[g][i] = 1;
        t ^= b[i];
      } else
        nn[g][i] = 0;
    }
    if (t != 0) bad = 1;
  }
  for (int it = 0; it < sz; it++) {
    int ok = 0;
    for (int i = 0; i < sz; i++)
      if (!did[i]) {
        int v = -1;
        for (int j = 0; j < sz; j++) need[j] = nn[i][j];
        gau();
        for (int j = 0; j < sz; j++)
          if (!did[j] && r[j] == 1) {
            v = j;
            break;
          }
        if (v != -1) {
          ok = 1;
          if (i != v) {
            for (int j = 0; j < sz; j++) swap(cont[i][j], cont[v][j]);
            go(v, i);
            go(i, v);
            go(v, i);
          }
          build(i, 1);
          did[i] = 1;
          break;
        }
      }
    if (!ok) break;
  }
  for (int i = 0; i < sz; i++)
    if (!did[i]) {
      for (int j = 0; j < sz; j++) need[j] = nn[i][j];
      gau();
      for (int j = 0; j < sz; j++) mem[i][j] = r[j];
    }
  for (int i = 0; i < sz; i++)
    if (!did[i]) {
      for (int j = 0; j < sz; j++) r[j] = mem[i][j];
      build(i, 0);
    }
  for (int i = 0; i < n; i++)
    if (x[i] != y[i]) {
      puts("-1");
      return 0;
    }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}