#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
int ary[10005];
int bry[10005];
vector<pair<int, int> > ans;
int pivot[31], pid[31];
int pivot2[31], pid2[31];
bool vis[10005];
void solve(int n, int a[]) {
  for (int i = 0; i < 31; ++i) pid[i] = -1;
  for (int k = 0; k < n; ++k) {
    int v = a[k];
    for (int i = 31 - 1; i >= 0; --i) {
      if (pid[i] == -1) continue;
      if (v & (1 << i)) v ^= pivot[i], ans.push_back(make_pair(k, pid[i]));
    }
    if (v == 0) continue;
    for (int i = 31 - 1; i >= 0; --i) {
      if (v & (1 << i)) {
        assert(pid[i] == -1);
        pivot[i] = v, pid[i] = k;
        for (int j = 0; j < 31; ++j)
          if (pid[j] != -1 and i != j and pivot[j] & (1 << i))
            pivot[j] ^= pivot[i], ans.push_back(make_pair(pid[j], pid[i]));
        break;
      }
    }
  }
}
bool solve3(vector<pair<int, int> > candi);
bool solve2(int n, int a[]) {
  for (int k = 0; k < n; ++k) {
    if (vis[k]) continue;
    int v = a[k];
    for (int i = 31 - 1; i >= 0; --i) {
      if (pid[i] == -1) continue;
      if (v & (1 << i)) v ^= pivot[i], ans.push_back(make_pair(k, pid[i]));
    }
    if (v != 0) return false;
  }
  vector<pair<int, int> > candi;
  for (int i = 31 - 1; i >= 0; --i)
    if (pid[i] != -1) candi.push_back(make_pair(a[pid[i]], pid[i]));
  return solve3(candi);
}
bool solve3(vector<pair<int, int> > candi) {
  vector<pair<int, int> > buf;
  for (int i = 0; i < 31; ++i) pid2[i] = -1;
  for (const auto &p : candi) {
    int k = p.second;
    int v = p.first;
    for (int i = 31 - 1; i >= 0; --i) {
      if (pid2[i] == -1) continue;
      if (v & (1 << i)) v ^= pivot2[i], buf.push_back(make_pair(k, pid2[i]));
    }
    if (v == 0) continue;
    for (int i = 31 - 1; i >= 0; --i) {
      if (v & (1 << i)) {
        assert(pid2[i] == -1);
        pivot2[i] = v, pid2[i] = k;
        for (int j = 0; j < 31; ++j)
          if (pid2[j] != -1 and i != j and pivot2[j] & (1 << i))
            pivot2[j] ^= pivot2[i], buf.push_back(make_pair(pid2[j], pid2[i]));
        break;
      }
    }
  }
  for (int i = 31 - 1; i >= 0; --i) {
    int a = pid[i];
    int b = pid2[i];
    if (a == -1 and b == -1) continue;
    if (a == -1 and b != -1)
      return false;
    else if (a != -1 and b == -1)
      ans.push_back(make_pair(a, a));
    else {
      int d = pivot[i] ^ pivot2[i];
      for (int j = i - 1; j >= 0; --j)
        if (pid[j] != -1 and d & (1 << j))
          d ^= pivot[j], ans.push_back(make_pair(pid[i], pid[j]));
      if (d != 0) return false;
      if (a == b) continue;
      ans.push_back(make_pair(pid[i], b));
      ans.push_back(make_pair(b, pid[i]));
      ans.push_back(make_pair(pid[i], b));
      for (int j = 0; j < 31; ++j)
        if (pid[j] == b) {
          swap(pid[i], pid[j]);
          break;
        }
    }
  }
  reverse((buf).begin(), (buf).end());
  for (const auto &p : buf) ans.push_back(p);
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &ary[i]);
  solve(n, ary);
  for (int i = 0; i < 31; ++i)
    if (pid[i] != -1) vis[pid[i]] = true;
  for (int i = 0; i < n; ++i) scanf("%d", &bry[i]);
  bool posi = solve2(n, bry);
  if (not posi)
    printf("-1");
  else {
    printf("%d\n", ((int)(ans).size()));
    for (const auto &p : ans) printf("%d %d\n", p.first + 1, p.second + 1);
  }
}

### Prompt

Create a solution in Cpp for 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;
const double eps = 1e-7;
int ary[10005];
int bry[10005];
vector<pair<int, int> > ans;
int pivot[31], pid[31];
int pivot2[31], pid2[31];
bool vis[10005];
void solve(int n, int a[]) {
  for (int i = 0; i < 31; ++i) pid[i] = -1;
  for (int k = 0; k < n; ++k) {
    int v = a[k];
    for (int i = 31 - 1; i >= 0; --i) {
      if (pid[i] == -1) continue;
      if (v & (1 << i)) v ^= pivot[i], ans.push_back(make_pair(k, pid[i]));
    }
    if (v == 0) continue;
    for (int i = 31 - 1; i >= 0; --i) {
      if (v & (1 << i)) {
        assert(pid[i] == -1);
        pivot[i] = v, pid[i] = k;
        for (int j = 0; j < 31; ++j)
          if (pid[j] != -1 and i != j and pivot[j] & (1 << i))
            pivot[j] ^= pivot[i], ans.push_back(make_pair(pid[j], pid[i]));
        break;
      }
    }
  }
}
bool solve3(vector<pair<int, int> > candi);
bool solve2(int n, int a[]) {
  for (int k = 0; k < n; ++k) {
    if (vis[k]) continue;
    int v = a[k];
    for (int i = 31 - 1; i >= 0; --i) {
      if (pid[i] == -1) continue;
      if (v & (1 << i)) v ^= pivot[i], ans.push_back(make_pair(k, pid[i]));
    }
    if (v != 0) return false;
  }
  vector<pair<int, int> > candi;
  for (int i = 31 - 1; i >= 0; --i)
    if (pid[i] != -1) candi.push_back(make_pair(a[pid[i]], pid[i]));
  return solve3(candi);
}
bool solve3(vector<pair<int, int> > candi) {
  vector<pair<int, int> > buf;
  for (int i = 0; i < 31; ++i) pid2[i] = -1;
  for (const auto &p : candi) {
    int k = p.second;
    int v = p.first;
    for (int i = 31 - 1; i >= 0; --i) {
      if (pid2[i] == -1) continue;
      if (v & (1 << i)) v ^= pivot2[i], buf.push_back(make_pair(k, pid2[i]));
    }
    if (v == 0) continue;
    for (int i = 31 - 1; i >= 0; --i) {
      if (v & (1 << i)) {
        assert(pid2[i] == -1);
        pivot2[i] = v, pid2[i] = k;
        for (int j = 0; j < 31; ++j)
          if (pid2[j] != -1 and i != j and pivot2[j] & (1 << i))
            pivot2[j] ^= pivot2[i], buf.push_back(make_pair(pid2[j], pid2[i]));
        break;
      }
    }
  }
  for (int i = 31 - 1; i >= 0; --i) {
    int a = pid[i];
    int b = pid2[i];
    if (a == -1 and b == -1) continue;
    if (a == -1 and b != -1)
      return false;
    else if (a != -1 and b == -1)
      ans.push_back(make_pair(a, a));
    else {
      int d = pivot[i] ^ pivot2[i];
      for (int j = i - 1; j >= 0; --j)
        if (pid[j] != -1 and d & (1 << j))
          d ^= pivot[j], ans.push_back(make_pair(pid[i], pid[j]));
      if (d != 0) return false;
      if (a == b) continue;
      ans.push_back(make_pair(pid[i], b));
      ans.push_back(make_pair(b, pid[i]));
      ans.push_back(make_pair(pid[i], b));
      for (int j = 0; j < 31; ++j)
        if (pid[j] == b) {
          swap(pid[i], pid[j]);
          break;
        }
    }
  }
  reverse((buf).begin(), (buf).end());
  for (const auto &p : buf) ans.push_back(p);
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &ary[i]);
  solve(n, ary);
  for (int i = 0; i < 31; ++i)
    if (pid[i] != -1) vis[pid[i]] = true;
  for (int i = 0; i < n; ++i) scanf("%d", &bry[i]);
  bool posi = solve2(n, bry);
  if (not posi)
    printf("-1");
  else {
    printf("%d\n", ((int)(ans).size()));
    for (const auto &p : ans) printf("%d %d\n", p.first + 1, p.second + 1);
  }
}

```