#include <bits/stdc++.h>
#pragma warning(disable : 4244 4267 4018 4996 4800)
using namespace std;
istream& in = cin;
ostream& out = cout;
int decompose(vector<int>& x, vector<int>& bits, vector<pair<int, int> >& ops) {
  int pos = 0;
  bits.resize(32, -1);
  for (int bit = 0; bit < 32; ++bit) {
    for (int j = pos; j < x.size(); ++j) {
      if (x[j] & (1 << bit)) {
        if (pos != j) {
          ops.push_back(make_pair(pos, j));
          ops.push_back(make_pair(j, pos));
          ops.push_back(make_pair(pos, j));
          swap(x[j], x[pos]);
        }
        for (int k = 0; k < x.size(); ++k) {
          if (k != pos && (x[k] & (1 << bit))) {
            x[k] ^= x[pos];
            ops.push_back(make_pair(k, pos));
          }
        }
        bits[bit] = pos;
        ++pos;
        break;
      }
    }
  }
  return pos;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  in >> n;
  vector<int> x(n), y(n);
  vector<pair<int, int> > ops;
  for (auto& t : x) in >> t;
  for (auto& t : y) in >> t;
  vector<int> xorig = x;
  vector<pair<int, int> > ops1, ops2;
  vector<int> bits;
  int len2 = decompose(y, bits, ops2);
  int len1 = decompose(x, bits, ops1);
  for (int j = 0; j < len2; ++j) {
    vector<int> w;
    for (int bit = 0; bit < 32; ++bit) {
      if (y[j] & (1 << bit)) {
        if (bits[bit] == -1) {
          out << -1;
          return 0;
        }
        int k = bits[bit];
        w.push_back(k);
        y[j] ^= x[k];
      }
    }
    if (y[j] != 0) {
      out << -1;
      return 0;
    }
    if (w.front() > j) ops1.push_back(make_pair(j, j));
    for (int k : w)
      if (k != j) ops1.push_back(make_pair(j, k));
  }
  for (int i = len2; i < len1; ++i) ops1.push_back(make_pair(i, i));
  reverse((ops2).begin(), (ops2).end());
  ops1.insert(ops1.end(), (ops2).begin(), (ops2).end());
  out << ops1.size() << "\n";
  for (int i = 0; i < ops1.size(); ++i) {
    xorig[ops1[i].first] ^= xorig[ops1[i].second];
    out << ops1[i].first + 1 << ' ' << ops1[i].second + 1 << "\n";
  }
  return 0;
}

### Prompt

In Cpp, your task is to solve the following 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.

### Response

```cpp
#include <bits/stdc++.h>
#pragma warning(disable : 4244 4267 4018 4996 4800)
using namespace std;
istream& in = cin;
ostream& out = cout;
int decompose(vector<int>& x, vector<int>& bits, vector<pair<int, int> >& ops) {
  int pos = 0;
  bits.resize(32, -1);
  for (int bit = 0; bit < 32; ++bit) {
    for (int j = pos; j < x.size(); ++j) {
      if (x[j] & (1 << bit)) {
        if (pos != j) {
          ops.push_back(make_pair(pos, j));
          ops.push_back(make_pair(j, pos));
          ops.push_back(make_pair(pos, j));
          swap(x[j], x[pos]);
        }
        for (int k = 0; k < x.size(); ++k) {
          if (k != pos && (x[k] & (1 << bit))) {
            x[k] ^= x[pos];
            ops.push_back(make_pair(k, pos));
          }
        }
        bits[bit] = pos;
        ++pos;
        break;
      }
    }
  }
  return pos;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  in >> n;
  vector<int> x(n), y(n);
  vector<pair<int, int> > ops;
  for (auto& t : x) in >> t;
  for (auto& t : y) in >> t;
  vector<int> xorig = x;
  vector<pair<int, int> > ops1, ops2;
  vector<int> bits;
  int len2 = decompose(y, bits, ops2);
  int len1 = decompose(x, bits, ops1);
  for (int j = 0; j < len2; ++j) {
    vector<int> w;
    for (int bit = 0; bit < 32; ++bit) {
      if (y[j] & (1 << bit)) {
        if (bits[bit] == -1) {
          out << -1;
          return 0;
        }
        int k = bits[bit];
        w.push_back(k);
        y[j] ^= x[k];
      }
    }
    if (y[j] != 0) {
      out << -1;
      return 0;
    }
    if (w.front() > j) ops1.push_back(make_pair(j, j));
    for (int k : w)
      if (k != j) ops1.push_back(make_pair(j, k));
  }
  for (int i = len2; i < len1; ++i) ops1.push_back(make_pair(i, i));
  reverse((ops2).begin(), (ops2).end());
  ops1.insert(ops1.end(), (ops2).begin(), (ops2).end());
  out << ops1.size() << "\n";
  for (int i = 0; i < ops1.size(); ++i) {
    xorig[ops1[i].first] ^= xorig[ops1[i].second];
    out << ops1[i].first + 1 << ' ' << ops1[i].second + 1 << "\n";
  }
  return 0;
}

```