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 x[10005], y[10005];
int solve(vector<int> a, int b) {
  vector<int> c(30);
  for (int i = 0; i < a.size(); ++i)
    for (int j = 0; j < 30; ++j)
      if (a[i] & (1 << j)) c[j] += (1 << i);
  for (int j = 0; j < 30; ++j)
    if (b & (1 << j)) c[j] += (1 << a.size());
  for (int j = 0; j <= a.size(); ++j) {
    for (int i = 0; i < c.size(); ++i) {
      if ((c[i] & (1 << j)) && (c[i] % (1 << j) == 0)) {
        if (j == a.size()) return -1;
        for (int k = 0; k < c.size(); ++k) {
          if (i != k && (c[k] & (1 << j))) {
            c[k] ^= c[i];
          }
        }
        break;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < c.size(); ++i)
    if (c[i] & (1 << a.size()))
      for (int j = 0; j < a.size(); ++j)
        if (c[i] & (1 << j)) ans += (1 << j);
  return ans;
}
vector<int> independent;
vector<int> getSet(vector<int> v) {
  vector<int> ans;
  for (int i = 0; i < v.size(); ++i) ans.push_back(x[v[i]]);
  return ans;
}
vector<pair<int, int> > ans;
void print(int ind, int res) {
  for (int i = 0; i < 31; ++i) {
    if (res & (1 << i)) {
      ans.push_back(make_pair(ind, independent[i]));
      x[ind] ^= x[independent[i]];
    }
  }
}
int perform(int ind, int other) {
  ind = independent[ind];
  other = independent[other];
  ans.push_back(make_pair(ind, other));
  x[ind] ^= x[other];
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", x + i);
  for (int i = 0; i < n; ++i) scanf("%d", y + i);
  for (int i = 0; i < n; ++i) {
    int res = solve(getSet(independent), x[i]);
    if (res == -1)
      independent.push_back(i);
    else {
      ans.push_back(make_pair(i, i));
      x[i] = 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    int res = solve(getSet(independent), y[i]);
    if (res == -1) {
      puts("-1");
      return 0;
    }
    if (x[i] == 0) print(i, res);
  }
  while (true) {
    vector<int> v;
    while (true) {
      bool any = 0;
      v.clear();
      for (int i = 0; i < independent.size(); ++i) {
        int I = independent[i];
        if (x[I] == y[I]) continue;
        int res = solve(getSet(independent), y[I]);
        if (res & (1 << i)) {
          any = 1;
          for (int j = 0; j < independent.size(); ++j)
            if (j != i && (res & (1 << j))) perform(i, j);
        } else
          v.push_back(i);
      }
      if (!any) break;
    }
    bool any = 0;
    for (int j = 0; j < v.size(); ++j) {
      int i = v[j];
      int I = independent[i];
      int res = solve(getSet(independent), y[I]);
      if (res & (1 << i)) {
        puts("ERROR!");
        return 0;
      }
      for (int k = 0; k < v.size(); ++k) {
        if (res & (1 << v[k])) {
          perform(v[k], v[j]);
          any = 1;
          assert(solve(getSet(independent), y[I]) & (1 << i));
          break;
        }
      }
      if (any) break;
    }
    if (!any) break;
  }
  vector<int> nInd;
  for (int i = 0; i < independent.size(); ++i) {
    int I = independent[i];
    if (x[I] == y[I])
      nInd.push_back(I);
    else {
      ans.push_back(make_pair(I, I));
      x[I] = 0;
    }
  }
  vector<int> old = independent;
  independent = nInd;
  for (int i = 0; i < old.size(); ++i) {
    if (x[old[i]] == y[old[i]]) continue;
    int res = solve(getSet(independent), y[old[i]]);
    if (res == -1) {
      puts("Weird");
      return 0;
    }
    for (int j = 0; j < independent.size(); ++j) {
      if (res & (1 << j)) {
        ans.push_back(make_pair(old[i], independent[j]));
        x[old[i]] ^= x[independent[j]];
      }
    }
    if (x[old[i]] != y[old[i]]) {
      puts("Strange");
      return 0;
    }
  }
  for (int i = 0; i < n; ++i) assert(x[i] == y[i]);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i)
    printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
}