#include <bits/stdc++.h>
using namespace std;
int max_bit(int a) {
  if (a == 0) return -1;
  return 1 + max_bit(a >> 1);
}
void imp() {
  printf("-1\n");
  exit(0);
}
void ass(int a, int b, vector<int> &v1, vector<pair<int, int> > &v2) {
  v1[a] ^= v1[b];
  v2.push_back(make_pair(a, b));
}
int n;
int first[10005];
int second[10005];
vector<pair<int, int> > comm;
vector<int> nums;
void ass(int a, int b) { ass(a, b, nums, comm); }
void gen_min() {
  comm.clear();
  int pt = 0;
  for (int i = 30; i >= 0; --i) {
    int first = -1;
    for (int j = pt; j < nums.size(); ++j)
      if (nums[j] & (1 << i)) first = j;
    if (first == -1) continue;
    if (first != pt) {
      ass(pt, first);
      ass(first, pt);
      ass(pt, first);
    }
    for (int j = 0; j < nums.size(); ++j)
      if (j != pt)
        if (nums[j] & (1 << i)) ass(j, pt);
    ++pt;
  }
}
vector<pair<int, int> > sol;
bool kor[10005];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", first + i);
  for (int i = 0; i < n; ++i) scanf("%d", second + i);
  vector<pair<int, int> > c1, c2;
  vector<int> a1, a2;
  for (int i = 0; i < n; ++i) {
    a1.push_back(first[i]);
    a2.push_back(second[i]);
  }
  nums = a1;
  gen_min();
  c1 = comm;
  a1 = nums;
  nums = a2;
  gen_min();
  c2 = comm;
  a2 = nums;
  sol = c1;
  int pos = 0;
  for (int i = 0; i < n; ++i) {
    if (a2[i] == 0) break;
    vector<int> used;
    int first = a2[i];
    for (int j = pos; j < n; ++j) {
      if (a1[j] == 0) break;
      if (first == 0) break;
      if (max_bit(first) == max_bit(a1[j])) {
        used.push_back(j);
        first ^= a1[j];
      }
    }
    if (first) imp();
    pos = used[0] + 1;
    kor[pos - 1] = true;
    for (int j = 1; j < used.size(); ++j) ass(used[0], used[j], a1, sol);
  }
  pos = 0;
  for (int i = 0; i < n; ++i) {
    if (!kor[i]) {
      ass(i, i, a1, sol);
      continue;
    }
    if (i == pos) {
      ++pos;
      continue;
    }
    ass(pos++, i, a1, sol);
    ass(i, i, a1, sol);
  }
  for (int i = c2.size() - 1; i >= 0; --i) sol.push_back(c2[i]);
  printf("%d\n", sol.size());
  for (int i = 0; i < sol.size(); ++i)
    printf("%d %d\n", sol[i].first + 1, sol[i].second + 1);
  return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

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;
int max_bit(int a) {
  if (a == 0) return -1;
  return 1 + max_bit(a >> 1);
}
void imp() {
  printf("-1\n");
  exit(0);
}
void ass(int a, int b, vector<int> &v1, vector<pair<int, int> > &v2) {
  v1[a] ^= v1[b];
  v2.push_back(make_pair(a, b));
}
int n;
int first[10005];
int second[10005];
vector<pair<int, int> > comm;
vector<int> nums;
void ass(int a, int b) { ass(a, b, nums, comm); }
void gen_min() {
  comm.clear();
  int pt = 0;
  for (int i = 30; i >= 0; --i) {
    int first = -1;
    for (int j = pt; j < nums.size(); ++j)
      if (nums[j] & (1 << i)) first = j;
    if (first == -1) continue;
    if (first != pt) {
      ass(pt, first);
      ass(first, pt);
      ass(pt, first);
    }
    for (int j = 0; j < nums.size(); ++j)
      if (j != pt)
        if (nums[j] & (1 << i)) ass(j, pt);
    ++pt;
  }
}
vector<pair<int, int> > sol;
bool kor[10005];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", first + i);
  for (int i = 0; i < n; ++i) scanf("%d", second + i);
  vector<pair<int, int> > c1, c2;
  vector<int> a1, a2;
  for (int i = 0; i < n; ++i) {
    a1.push_back(first[i]);
    a2.push_back(second[i]);
  }
  nums = a1;
  gen_min();
  c1 = comm;
  a1 = nums;
  nums = a2;
  gen_min();
  c2 = comm;
  a2 = nums;
  sol = c1;
  int pos = 0;
  for (int i = 0; i < n; ++i) {
    if (a2[i] == 0) break;
    vector<int> used;
    int first = a2[i];
    for (int j = pos; j < n; ++j) {
      if (a1[j] == 0) break;
      if (first == 0) break;
      if (max_bit(first) == max_bit(a1[j])) {
        used.push_back(j);
        first ^= a1[j];
      }
    }
    if (first) imp();
    pos = used[0] + 1;
    kor[pos - 1] = true;
    for (int j = 1; j < used.size(); ++j) ass(used[0], used[j], a1, sol);
  }
  pos = 0;
  for (int i = 0; i < n; ++i) {
    if (!kor[i]) {
      ass(i, i, a1, sol);
      continue;
    }
    if (i == pos) {
      ++pos;
      continue;
    }
    ass(pos++, i, a1, sol);
    ass(i, i, a1, sol);
  }
  for (int i = c2.size() - 1; i >= 0; --i) sol.push_back(c2[i]);
  printf("%d\n", sol.size());
  for (int i = 0; i < sol.size(); ++i)
    printf("%d %d\n", sol[i].first + 1, sol[i].second + 1);
  return 0;
}

```