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;
const int N = 10005;
int getBit(int x) {
  int ret = 0;
  while (x) {
    x >>= 1;
    ++ret;
  }
  return ret - 1;
}
vector<int> clear(vector<int> &x, vector<pair<int, int> > &ans) {
  int base = 0;
  vector<int> bit;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < base; ++j) {
      if (x[i] >> bit[j] & 1) {
        x[i] ^= x[j];
        ans.push_back(make_pair(i, j));
      }
    }
    if (x[i]) {
      if (i != base) {
        ans.push_back(make_pair(base, i));
        ans.push_back(make_pair(i, base));
        ans.push_back(make_pair(base, i));
        swap(x[i], x[base]);
      }
      bit.push_back(getBit(x[base]));
      ++base;
      for (int j = 0; j < base; ++j) {
        for (int k = j + 1; k < base; ++k) {
          if (bit[k] > bit[j]) {
            ans.push_back(make_pair(j, k));
            ans.push_back(make_pair(k, j));
            ans.push_back(make_pair(j, k));
            swap(x[j], x[k]);
            swap(bit[j], bit[k]);
          }
        }
      }
      for (int j = 0; j < base; ++j) {
        for (int k = j + 1; k < base; ++k) {
          if (x[j] >> bit[k] & 1) {
            ans.push_back(make_pair(j, k));
            x[j] ^= x[k];
          }
        }
      }
    }
  }
  return bit;
}
vector<int> x, y;
bool trans(vector<int> &bitx, vector<int> &bity, vector<pair<int, int> > &mid) {
  int n = bitx.size(), m = bity.size();
  if (n < m) {
    return false;
  }
  int j = 0;
  for (int i = 0; i < n; ++i) {
    if (j == m) {
      mid.push_back(make_pair(i, i));
      x[i] = 0;
      continue;
    }
    if (bitx[i] > bity[j]) {
      mid.push_back(make_pair(i, i));
      x[i] = 0;
      continue;
    }
    if (bitx[i] < bity[j]) {
      return false;
    }
    int delta = x[i] ^ y[j];
    for (int k = i + 1; k < n; ++k) {
      if (delta >> bitx[k] & 1) {
        delta ^= x[k];
        mid.push_back(make_pair(i, k));
        x[i] ^= x[k];
      }
    }
    if (delta) {
      return false;
    }
    ++j;
  }
  if (j != m) {
    return false;
  }
  for (int i = n - 1; i >= 0; --i) {
    if (x[i] == 0) {
      for (int j = i; j + 1 < n; ++j) {
        x[j] = x[j + 1];
        mid.push_back(make_pair(j, j + 1));
        mid.push_back(make_pair(j + 1, j + 1));
      }
      x[n - 1] = 0;
      --n;
    }
  }
  return true;
}
bool check(vector<int> x, vector<int> y, vector<pair<int, int> > ans) {
  for (int i = 0; i < (int)ans.size(); ++i) {
    int u = ans[i].first, v = ans[i].second;
    x[u] ^= x[v];
  }
  return x == y;
}
int main() {
  scanf("%d", &n);
  x.resize(n), y.resize(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &y[i]);
  }
  vector<int> cx = x, cy = y;
  vector<pair<int, int> > ans1, ans2, mid;
  vector<int> bitx, bity;
  bitx = clear(x, ans1);
  bity = clear(y, ans2);
  if (trans(bitx, bity, mid)) {
    assert(x == y);
    vector<pair<int, int> > full = ans1;
    full.insert(full.end(), mid.begin(), mid.end());
    reverse(ans2.begin(), ans2.end());
    full.insert(full.end(), ans2.begin(), ans2.end());
    printf("%d\n", (int)full.size());
    for (int i = 0; i < (int)full.size(); ++i) {
      printf("%d %d\n", full[i].first + 1, full[i].second + 1);
    }
    assert(check(cx, cy, full));
  } else {
    printf("-1\n");
  }
  return 0;
}