#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 10007, lglg = 31, L = lglg + 2;
inline void failure() {
  cout << -1 << lf;
  exit(0);
}
int n, px[_], py[_];
int gay[L] = {0}, isgay[_] = {0}, via[_] = {0};
vector<pair<int, int>> ans, ans2;
inline void add(int a, int b) { ans.emplace_back(a, b); }
inline void add2(int a, int b) { ans2.emplace_back(a, b); }
int bs[_] = {0}, vs[_] = {0}, lps = 0;
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty();
  for (int i = 1; i <= n; i++) px[i] = ty();
  for (int i = 1; i <= n; i++) py[i] = ty();
  for (int i = 1; i <= n; i++) {
    isgay[i] = -1;
    for (int j = lglg, a = 0; j >= 0; j--) {
      if (!(((px[i]) >> (j)) & 1)) continue;
      if (gay[j])
        px[i] ^= px[gay[j]], a ^= via[j];
      else {
        isgay[i] = j, gay[j] = i, via[j] = a | (1 << (j));
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int a = 0;
    for (int j = lglg; j >= 0; j--) {
      if (!(((py[i]) >> (j)) & 1)) continue;
      if (!gay[j]) failure();
      py[i] ^= px[gay[j]], a ^= via[j];
    }
    if (isgay[i] >= 0) {
      bs[lps] = i, vs[lps] = a, lps++;
      continue;
    }
    add(i, i);
    for (int j = lglg; j >= 0; j--)
      if ((((a) >> (j)) & 1)) add(i, gay[j]);
  }
  for (int i = 0; i < lps; i++) {
    int a = vs[i];
    vs[i] = 0;
    for (int j = 0; j < lps; j++)
      if ((((a) >> (isgay[bs[j]])) & 1)) vs[i] |= (1 << (j));
  }
  for (int i = 0; i < lps; i++) {
    if (!(((vs[i]) >> (i)) & 1))
      for (int j = i + 1; j < lps; j++)
        if ((((vs[j]) >> (i)) & 1)) {
          add2(bs[i], bs[j]), add2(bs[j], bs[i]), add2(bs[i], bs[j]),
              swap(vs[i], vs[j]);
          break;
        }
    if ((((vs[i]) >> (i)) & 1))
      for (int j = i + 1; j < lps; j++)
        if ((((vs[j]) >> (i)) & 1)) add2(bs[j], bs[i]), vs[j] ^= vs[i];
  }
  for (int i = 0; i < lps; i++) {
    if (!(((vs[i]) >> (i)) & 1)) add(bs[i], bs[i]);
    for (int j = i + 1; j < lps; j++)
      if ((((vs[i]) >> (j)) & 1)) add(bs[i], bs[j]);
  }
  reverse(ans2.begin(), ans2.end()),
      ans.insert(ans.end(), ans2.begin(), ans2.end());
  cout << ans.size() << lf;
  for (auto i : ans) cout << i.first << ' ' << i.second << lf;
  return 0;
}

### Prompt

Please provide a CPP coded solution 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;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 10007, lglg = 31, L = lglg + 2;
inline void failure() {
  cout << -1 << lf;
  exit(0);
}
int n, px[_], py[_];
int gay[L] = {0}, isgay[_] = {0}, via[_] = {0};
vector<pair<int, int>> ans, ans2;
inline void add(int a, int b) { ans.emplace_back(a, b); }
inline void add2(int a, int b) { ans2.emplace_back(a, b); }
int bs[_] = {0}, vs[_] = {0}, lps = 0;
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty();
  for (int i = 1; i <= n; i++) px[i] = ty();
  for (int i = 1; i <= n; i++) py[i] = ty();
  for (int i = 1; i <= n; i++) {
    isgay[i] = -1;
    for (int j = lglg, a = 0; j >= 0; j--) {
      if (!(((px[i]) >> (j)) & 1)) continue;
      if (gay[j])
        px[i] ^= px[gay[j]], a ^= via[j];
      else {
        isgay[i] = j, gay[j] = i, via[j] = a | (1 << (j));
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int a = 0;
    for (int j = lglg; j >= 0; j--) {
      if (!(((py[i]) >> (j)) & 1)) continue;
      if (!gay[j]) failure();
      py[i] ^= px[gay[j]], a ^= via[j];
    }
    if (isgay[i] >= 0) {
      bs[lps] = i, vs[lps] = a, lps++;
      continue;
    }
    add(i, i);
    for (int j = lglg; j >= 0; j--)
      if ((((a) >> (j)) & 1)) add(i, gay[j]);
  }
  for (int i = 0; i < lps; i++) {
    int a = vs[i];
    vs[i] = 0;
    for (int j = 0; j < lps; j++)
      if ((((a) >> (isgay[bs[j]])) & 1)) vs[i] |= (1 << (j));
  }
  for (int i = 0; i < lps; i++) {
    if (!(((vs[i]) >> (i)) & 1))
      for (int j = i + 1; j < lps; j++)
        if ((((vs[j]) >> (i)) & 1)) {
          add2(bs[i], bs[j]), add2(bs[j], bs[i]), add2(bs[i], bs[j]),
              swap(vs[i], vs[j]);
          break;
        }
    if ((((vs[i]) >> (i)) & 1))
      for (int j = i + 1; j < lps; j++)
        if ((((vs[j]) >> (i)) & 1)) add2(bs[j], bs[i]), vs[j] ^= vs[i];
  }
  for (int i = 0; i < lps; i++) {
    if (!(((vs[i]) >> (i)) & 1)) add(bs[i], bs[i]);
    for (int j = i + 1; j < lps; j++)
      if ((((vs[i]) >> (j)) & 1)) add(bs[i], bs[j]);
  }
  reverse(ans2.begin(), ans2.end()),
      ans.insert(ans.end(), ans2.begin(), ans2.end());
  cout << ans.size() << lf;
  for (auto i : ans) cout << i.first << ' ' << i.second << lf;
  return 0;
}

```