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;
template <class T>
bool smin(T &_x, T &_y) {
  return _x <= _y ? false : ((_x = _y), true);
}
template <class T>
bool smax(T &_x, T &_y) {
  return _x >= _y ? false : ((_x = _y), true);
}
const int maxn = 1e5 + 5;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int lg = 30;
bool mark[maxn];
int n;
inline int get_right(int x) { return x == 0 ? (1 << lg) : x & -x; }
struct space {
  vector<pair<int, int> > to_do_list;
  int bv[lg];
  int m;
  bool add(int x, int idx) {
    for (int i = 0; i < m; i++)
      if (x & get_right(bv[i])) {
        x ^= bv[i];
        to_do_list.push_back(pair<int, int>(idx, i));
      }
    if (x == 0) return 0;
    for (int i = 0; i < m; i++)
      if (bv[i] & get_right(x)) {
        bv[i] ^= x;
        to_do_list.push_back(pair<int, int>(i, idx));
      }
    bv[m] = x;
    if (idx != m) {
      to_do_list.push_back(pair<int, int>(m, idx));
      to_do_list.push_back(pair<int, int>(idx, m));
    }
    m++;
    return 1;
  }
  void sort(int e) {
    if (e == 0) return;
    for (int i = 0; i < e - 1; i++) {
      if (get_right(bv[i]) > get_right(bv[i + 1])) {
        to_do_list.push_back(pair<int, int>(i, i + 1));
        to_do_list.push_back(pair<int, int>(i + 1, i));
        to_do_list.push_back(pair<int, int>(i, i + 1));
        swap(bv[i], bv[i + 1]);
      }
    }
    sort(e - 1);
  }
} x, y;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    x.add(a, i);
  }
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    y.add(a, i);
  }
  x.sort(x.m);
  y.sort(y.m);
  for (int i = 0; i < y.m; i++) {
    int _y = y.bv[i], p = -1;
    for (int j = 0; j < x.m; j++) {
      if (_y & get_right(x.bv[j])) {
        if (p == -1) {
          p = j;
        } else {
          x.to_do_list.push_back(pair<int, int>(p, j));
          x.bv[p] ^= x.bv[j];
        }
        _y ^= x.bv[j];
      }
    }
    if (_y != 0) {
      printf("-1\n");
      return 0;
    }
    if (p != -1) mark[p] = true;
  }
  for (int i = 0; i < x.m; i++) {
    if (!mark[i]) {
      x.bv[i] = 0;
      x.to_do_list.push_back(pair<int, int>(i, i));
    }
  }
  x.sort(x.m);
  printf("%d\n", x.to_do_list.size() + y.to_do_list.size());
  for (pair<int, int> p : x.to_do_list)
    printf("%d %d\n", p.first + 1, p.second + 1);
  reverse(y.to_do_list.begin(), y.to_do_list.end());
  for (pair<int, int> p : y.to_do_list)
    printf("%d %d\n", p.first + 1, p.second + 1);
}