#include <bits/stdc++.h>
using namespace std;
template <typename T>
T mabs(const T &a) {
  return a < 0 ? -a : a;
}
const int SZ = 10050;
int xs[SZ], ys[SZ];
int bnx[SZ], bny[SZ];
bool checkBit(int num, int bn) { return (num >> bn) & 1; }
int n;
bool inBas[SZ];
vector<pair<int, int> > buildBasis(int *nums, vector<int> &basNums, int *bnx) {
  memset(inBas, 0, sizeof(inBas));
  vector<pair<int, int> > res;
  for (int i = (0), ei = (30); i < ei; i++) {
    int cb = -1;
    for (int j = (0), ej = (n); j < ej; j++) {
      if (checkBit(nums[j], i) && !inBas[j]) {
        cb = j;
        break;
      }
    }
    basNums.push_back(cb);
    if (cb == -1) continue;
    bnx[cb] = i;
    inBas[cb] = 1;
    for (int j = (0), ej = (n); j < ej; j++) {
      if (j == cb) continue;
      if (checkBit(nums[j], i)) {
        nums[j] ^= nums[cb];
        res.push_back({j, cb});
      }
    }
  }
  return res;
}
void makeSwap(int *nums, int i, int j, vector<pair<int, int> > &to) {
  if (i == j) return;
  nums[i] ^= nums[j];
  to.push_back({i, j});
  nums[j] ^= nums[i];
  to.push_back({j, i});
  nums[i] ^= nums[j];
  to.push_back({i, j});
}
bool has(int num) { return num != -1; }
int y2[10050];
void run() {
  scanf("%d ", &n);
  memset(bnx, -1, sizeof(bnx));
  memset(bny, -1, sizeof(bny));
  for (int i = (0), ei = (n); i < ei; i++) {
    scanf("%d", xs + i);
  }
  for (int i = (0), ei = (n); i < ei; i++) {
    scanf("%d", ys + i);
  }
  vector<int> basNumsX, basNumsY;
  memcpy(y2, ys, sizeof(ys));
  vector<pair<int, int> > buildResY = buildBasis(ys, basNumsY, bny);
  vector<pair<int, int> > buildResX = buildBasis(xs, basNumsX, bnx);
  bool fail = 0;
  for (int i = (0), ei = (basNumsY.size()); i < ei; i++) {
    int numInY = basNumsY[i];
    int numInX = basNumsX[i];
    if (numInY == -1) {
      if (numInX != -1) {
        for (int j = (0), ej = (i); j < ej; j++) {
          if (basNumsY[j] == -1) continue;
          int yVal = ys[basNumsY[j]];
          int xVal = xs[basNumsX[j]];
          if (checkBit(yVal, i) != checkBit(xVal, i)) {
            xs[basNumsX[j]] ^= xs[basNumsX[i]];
            buildResX.push_back({basNumsX[j], basNumsX[i]});
          }
        }
        xs[basNumsX[i]] = 0;
        bnx[basNumsX[i]] = -1;
        buildResX.push_back({numInX, numInX});
        basNumsX[i] = -1;
      }
      continue;
    }
    if (numInX != numInY) {
      int curOnX = bnx[numInY];
      makeSwap(xs, numInX, numInY, buildResX);
      swap(bnx[numInX], bnx[numInY]);
      if (curOnX != -1) {
        basNumsX[curOnX] = basNumsX[i];
      }
      basNumsX[i] = basNumsY[i];
    }
  }
  if (!fail) {
    for (int i = (0), ei = (buildResY.size()); i < ei; i++) {
      pair<int, int> cv = buildResY[buildResY.size() - 1 - i];
      xs[cv.first] ^= xs[cv.second];
      buildResX.push_back(cv);
    }
    memcpy(ys, y2, sizeof(y2));
    for (int i = (0), ei = (n); i < ei; i++) {
      if (xs[i] != ys[i]) {
        fail = 1;
      }
    }
  }
  if (!fail) {
    printf("%d\n", (int)buildResX.size());
    for (int i = (0), ei = (buildResX.size()); i < ei; i++) {
      printf("%d %d\n", buildResX[i].first + 1, buildResX[i].second + 1);
    }
  } else
    printf("-1\n");
}
int main() {
  run();
  return 0;
}

### Prompt

Your task is to create 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 <typename T>
T mabs(const T &a) {
  return a < 0 ? -a : a;
}
const int SZ = 10050;
int xs[SZ], ys[SZ];
int bnx[SZ], bny[SZ];
bool checkBit(int num, int bn) { return (num >> bn) & 1; }
int n;
bool inBas[SZ];
vector<pair<int, int> > buildBasis(int *nums, vector<int> &basNums, int *bnx) {
  memset(inBas, 0, sizeof(inBas));
  vector<pair<int, int> > res;
  for (int i = (0), ei = (30); i < ei; i++) {
    int cb = -1;
    for (int j = (0), ej = (n); j < ej; j++) {
      if (checkBit(nums[j], i) && !inBas[j]) {
        cb = j;
        break;
      }
    }
    basNums.push_back(cb);
    if (cb == -1) continue;
    bnx[cb] = i;
    inBas[cb] = 1;
    for (int j = (0), ej = (n); j < ej; j++) {
      if (j == cb) continue;
      if (checkBit(nums[j], i)) {
        nums[j] ^= nums[cb];
        res.push_back({j, cb});
      }
    }
  }
  return res;
}
void makeSwap(int *nums, int i, int j, vector<pair<int, int> > &to) {
  if (i == j) return;
  nums[i] ^= nums[j];
  to.push_back({i, j});
  nums[j] ^= nums[i];
  to.push_back({j, i});
  nums[i] ^= nums[j];
  to.push_back({i, j});
}
bool has(int num) { return num != -1; }
int y2[10050];
void run() {
  scanf("%d ", &n);
  memset(bnx, -1, sizeof(bnx));
  memset(bny, -1, sizeof(bny));
  for (int i = (0), ei = (n); i < ei; i++) {
    scanf("%d", xs + i);
  }
  for (int i = (0), ei = (n); i < ei; i++) {
    scanf("%d", ys + i);
  }
  vector<int> basNumsX, basNumsY;
  memcpy(y2, ys, sizeof(ys));
  vector<pair<int, int> > buildResY = buildBasis(ys, basNumsY, bny);
  vector<pair<int, int> > buildResX = buildBasis(xs, basNumsX, bnx);
  bool fail = 0;
  for (int i = (0), ei = (basNumsY.size()); i < ei; i++) {
    int numInY = basNumsY[i];
    int numInX = basNumsX[i];
    if (numInY == -1) {
      if (numInX != -1) {
        for (int j = (0), ej = (i); j < ej; j++) {
          if (basNumsY[j] == -1) continue;
          int yVal = ys[basNumsY[j]];
          int xVal = xs[basNumsX[j]];
          if (checkBit(yVal, i) != checkBit(xVal, i)) {
            xs[basNumsX[j]] ^= xs[basNumsX[i]];
            buildResX.push_back({basNumsX[j], basNumsX[i]});
          }
        }
        xs[basNumsX[i]] = 0;
        bnx[basNumsX[i]] = -1;
        buildResX.push_back({numInX, numInX});
        basNumsX[i] = -1;
      }
      continue;
    }
    if (numInX != numInY) {
      int curOnX = bnx[numInY];
      makeSwap(xs, numInX, numInY, buildResX);
      swap(bnx[numInX], bnx[numInY]);
      if (curOnX != -1) {
        basNumsX[curOnX] = basNumsX[i];
      }
      basNumsX[i] = basNumsY[i];
    }
  }
  if (!fail) {
    for (int i = (0), ei = (buildResY.size()); i < ei; i++) {
      pair<int, int> cv = buildResY[buildResY.size() - 1 - i];
      xs[cv.first] ^= xs[cv.second];
      buildResX.push_back(cv);
    }
    memcpy(ys, y2, sizeof(y2));
    for (int i = (0), ei = (n); i < ei; i++) {
      if (xs[i] != ys[i]) {
        fail = 1;
      }
    }
  }
  if (!fail) {
    printf("%d\n", (int)buildResX.size());
    for (int i = (0), ei = (buildResX.size()); i < ei; i++) {
      printf("%d %d\n", buildResX[i].first + 1, buildResX[i].second + 1);
    }
  } else
    printf("-1\n");
}
int main() {
  run();
  return 0;
}

```