#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T a, T b) {
  ;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
namespace std {
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& a) {
  out << '(' << a.first << ',' << a.second << ')';
  return out;
}
}  // namespace std
long long int readL() {
  long long int res;
  scanf("%I64d", &res);
  return res;
}
void printL(long long int res) { printf("%I64d", res); }
int n;
int ar[10005];
int piv[35];
void swp(vector<pair<int, int> >& ans, int x, int y) {
  ans.push_back(make_pair(x, y));
  ans.push_back(make_pair(y, x));
  ans.push_back(make_pair(x, y));
  swap(ar[x], ar[y]);
}
int who[35];
int aff[35][10005];
pair<vector<pair<int, int> >, vector<int> > solve() {
  vector<pair<int, int> > ans;
  int rank = 0;
  vector<int> unit;
  for (int i = 0; i < 30; ++i) {
    int idx = -1;
    for (int j = (rank); j < (n); ++j)
      if (ar[j] >> i & 1) {
        idx = j;
        break;
      }
    if (idx == -1) continue;
    if (idx != rank) swp(ans, rank, idx);
    piv[rank] = i;
    for (int j = 0; j < (n); ++j)
      if (j != rank && ar[j] >> i & 1) {
        ans.push_back(make_pair(j, rank));
        ar[j] ^= ar[rank];
      }
    ++rank;
  }
  for (int i = 0; i < (rank); ++i) unit.push_back(ar[i]);
  return make_pair(ans, unit);
}
int mark[35];
int init1[10005], init2[10005];
int main() {
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    cin >> ar[i];
    init1[i] = ar[i];
  }
  pair<vector<pair<int, int> >, vector<int> > res_ = solve();
  vector<pair<int, int> > res = res_.first;
  for (int i = 0; i < (n); ++i) {
    cin >> ar[i];
    init2[i] = ar[i];
  }
  pair<vector<pair<int, int> >, vector<int> > res2_ = solve();
  vector<pair<int, int> > res2 = res2_.first;
  vector<int> A = res_.second, B = res2_.second;
  if (A.size() < B.size()) {
    puts("-1");
    return 0;
  }
  debug((A).begin(), (A).end());
  debug((B).begin(), (B).end());
  for (int i = 0; i < (A.size()); ++i) {
    int low = __builtin_ffs(A[i]) - 1;
    for (int j = 0; j < (B.size()); ++j)
      if (B[j] >> low & 1 && i != j) {
        res.push_back(make_pair(j, i));
        A[j] ^= A[i];
      }
    if (i >= B.size() || !(B[i] >> low & 1)) {
      A[i] = 0;
      res.push_back(make_pair(i, i));
    }
  }
  debug((A).begin(), (A).end());
  res.insert(res.end(), res2.rbegin(), res2.rend());
  for (int i = 0; i < (res.size()); ++i) {
    int a = res[i].first, b = res[i].second;
    init1[a] ^= init1[b];
  }
  debug(init1, init1 + n);
  debug(init2, init2 + n);
  int fail = 0;
  for (int i = 0; i < (n); ++i)
    if (init2[i] != init1[i]) fail = 1;
  if (fail)
    puts("-1");
  else {
    cout << res.size() << endl;
    for (int i = 0; i < (res.size()); ++i)
      printf("%d %d\n", res[i].first + 1, res[i].second + 1);
  }
  return 0;
}

### Prompt

Please formulate a CPP solution to 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>
using namespace std;
template <class T>
void debug(T a, T b) {
  ;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
namespace std {
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& a) {
  out << '(' << a.first << ',' << a.second << ')';
  return out;
}
}  // namespace std
long long int readL() {
  long long int res;
  scanf("%I64d", &res);
  return res;
}
void printL(long long int res) { printf("%I64d", res); }
int n;
int ar[10005];
int piv[35];
void swp(vector<pair<int, int> >& ans, int x, int y) {
  ans.push_back(make_pair(x, y));
  ans.push_back(make_pair(y, x));
  ans.push_back(make_pair(x, y));
  swap(ar[x], ar[y]);
}
int who[35];
int aff[35][10005];
pair<vector<pair<int, int> >, vector<int> > solve() {
  vector<pair<int, int> > ans;
  int rank = 0;
  vector<int> unit;
  for (int i = 0; i < 30; ++i) {
    int idx = -1;
    for (int j = (rank); j < (n); ++j)
      if (ar[j] >> i & 1) {
        idx = j;
        break;
      }
    if (idx == -1) continue;
    if (idx != rank) swp(ans, rank, idx);
    piv[rank] = i;
    for (int j = 0; j < (n); ++j)
      if (j != rank && ar[j] >> i & 1) {
        ans.push_back(make_pair(j, rank));
        ar[j] ^= ar[rank];
      }
    ++rank;
  }
  for (int i = 0; i < (rank); ++i) unit.push_back(ar[i]);
  return make_pair(ans, unit);
}
int mark[35];
int init1[10005], init2[10005];
int main() {
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    cin >> ar[i];
    init1[i] = ar[i];
  }
  pair<vector<pair<int, int> >, vector<int> > res_ = solve();
  vector<pair<int, int> > res = res_.first;
  for (int i = 0; i < (n); ++i) {
    cin >> ar[i];
    init2[i] = ar[i];
  }
  pair<vector<pair<int, int> >, vector<int> > res2_ = solve();
  vector<pair<int, int> > res2 = res2_.first;
  vector<int> A = res_.second, B = res2_.second;
  if (A.size() < B.size()) {
    puts("-1");
    return 0;
  }
  debug((A).begin(), (A).end());
  debug((B).begin(), (B).end());
  for (int i = 0; i < (A.size()); ++i) {
    int low = __builtin_ffs(A[i]) - 1;
    for (int j = 0; j < (B.size()); ++j)
      if (B[j] >> low & 1 && i != j) {
        res.push_back(make_pair(j, i));
        A[j] ^= A[i];
      }
    if (i >= B.size() || !(B[i] >> low & 1)) {
      A[i] = 0;
      res.push_back(make_pair(i, i));
    }
  }
  debug((A).begin(), (A).end());
  res.insert(res.end(), res2.rbegin(), res2.rend());
  for (int i = 0; i < (res.size()); ++i) {
    int a = res[i].first, b = res[i].second;
    init1[a] ^= init1[b];
  }
  debug(init1, init1 + n);
  debug(init2, init2 + n);
  int fail = 0;
  for (int i = 0; i < (n); ++i)
    if (init2[i] != init1[i]) fail = 1;
  if (fail)
    puts("-1");
  else {
    cout << res.size() << endl;
    for (int i = 0; i < (res.size()); ++i)
      printf("%d %d\n", res[i].first + 1, res[i].second + 1);
  }
  return 0;
}

```