#include <bits/stdc++.h>
using namespace std;
const int NMax = 10005;
const int lgValMax = 33;
int N;
int X[NMax], Y[NMax];
int A[2][NMax][lgValMax];
int first, Line[2][NMax], Pivot[2][NMax];
bool Use[NMax];
vector<pair<int, int> > Sol[2];
vector<pair<int, int> > Basis;
int Left[NMax], Right[NMax];
void Read() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> X[i];
    Line[0][i] = Line[1][i] = i;
  }
  first = X[1];
  for (int i = 1; i <= N; i++) cin >> Y[i];
}
void fillA(int ind, int line, int val) {
  for (int i = 0; i < 30; i++)
    if (val & (1 << i)) A[ind][line][i + 1] = 1;
}
void buildA(int ind) {
  for (int i = 1; i <= N; i++) {
    fillA(ind, i, X[i]);
  }
}
bool findPivot(int ind, int i, int j) {
  int k;
  for (k = i; k <= N && A[ind][k][j] == 0; k++)
    ;
  if (k == N + 1) {
    return 0;
  }
  if (k != i) {
    swap(A[ind][k], A[ind][i]);
    Sol[ind].push_back(make_pair(i, k));
    Sol[ind].push_back(make_pair(k, i));
    Sol[ind].push_back(make_pair(i, k));
  }
  return 1;
}
void fillOperation(int ind, int l1, int l2) {
  Sol[ind].push_back(make_pair(Line[ind][l2], Line[ind][l1]));
  for (int k = 1; k <= 30; k++) A[ind][l2][k] ^= A[ind][l1][k];
}
void toEF(int ind) {
  int i = 1, j = 1, k;
  while (i <= N && j <= 30) {
    if (!findPivot(ind, i, j)) {
      ++j;
      continue;
    }
    Pivot[ind][j] = i;
    for (int k = i + 1; k <= N; k++) {
      if (A[ind][k][j] == 1) fillOperation(ind, i, k);
    }
    ++i;
    ++j;
  }
}
void toREF(int ind) {
  for (int j = 30; j >= 1; j--) {
    if (Pivot[ind][j] == 0) continue;
    int piv = Pivot[ind][j];
    for (int k = piv - 1; k >= 1; k--)
      if (A[ind][k][j] == 1) fillOperation(ind, piv, k);
  }
}
void toUnit(int ind) {
  buildA(ind);
  toEF(ind);
  toREF(ind);
}
void swapXY() {
  for (int i = 1; i <= N; i++) swap(X[i], Y[i]);
}
void printSol() {
  printf("%d\n", Sol[0].size() + Sol[1].size());
  for (int i = 0; i < Sol[0].size(); i++)
    printf("%d %d\n", Sol[0][i].first, Sol[0][i].second);
  for (int i = Sol[1].size() - 1; i >= 0; i--)
    printf("%d %d\n", Sol[1][i].first, Sol[1][i].second);
}
bool check() {
  for (int i = 0; i < Sol[0].size(); i++) {
    X[Sol[0][i].first] ^= X[Sol[0][i].second];
  }
  for (int i = Sol[1].size() - 1; i >= 0; i--)
    X[Sol[1][i].first] ^= X[Sol[1][i].second];
  for (int i = 1; i <= N; i++)
    if (X[i] != Y[i]) return 0;
  return 1;
}
int convertNumber(int ind, int line) {
  int res = 0, p = 1;
  for (int i = 1; i <= 30; i++, p *= 2) res += A[ind][line][i] * p;
  return res;
}
bool cornerCase() {
  for (int i = 0; i < Basis.size(); i++) {
    X[Basis[i].first] ^= X[Basis[i].second];
  }
  for (int i = 1; i <= N; i++)
    if (X[i] != Y[i]) return 0;
  return 1;
}
bool basisTransition() {
  for (int i = 1; i <= N; i++) {
    X[i] = convertNumber(0, i);
    Y[i] = convertNumber(1, i);
  }
  for (int j = 1; j <= 30; j++) {
    int piv = Pivot[1][j];
    if (piv == 0) continue;
    int b = convertNumber(1, piv), aux = 0, first = 0;
    for (int k = 30; k >= 1; k--)
      if (A[1][piv][k] == 1 && Pivot[0][k] != 0) {
        aux ^= convertNumber(0, Pivot[0][k]), first = Pivot[0][k];
      }
    if (aux != b) return 0;
    for (int k = 1; k <= 30; k++)
      if (A[1][piv][k] == 1 && Pivot[0][k] != 0 && first != Pivot[0][k]) {
        Sol[0].push_back(make_pair(first, Pivot[0][k]));
        Basis.push_back(make_pair(first, Pivot[0][k]));
      }
    Left[first] = b;
  }
  for (int i = 1; i <= N; i++) {
    if (Right[i] == 0) continue;
    for (int j = 1; j <= N; j++)
      if (Right[i] == Left[j] && Use[j] == 0) {
        Use[j] = 1;
        if (i != j) {
          Sol[0].push_back(make_pair(i, j));
          Sol[0].push_back(make_pair(j, i));
          Sol[0].push_back(make_pair(i, j));
          Basis.push_back(make_pair(i, j));
          Basis.push_back(make_pair(j, i));
          Basis.push_back(make_pair(i, j));
          swap(Use[i], Use[j]);
          swap(Left[i], Left[j]);
        }
        break;
      }
  }
  for (int i = 1; i <= N; i++)
    if (Right[i] == 0) {
      Sol[0].push_back(make_pair(i, i));
      Basis.push_back(make_pair(i, i));
    }
  return 1;
}
void Solve() {
  toUnit(0);
  swapXY();
  toUnit(1);
  swapXY();
  for (int i = 1; i <= N; i++) {
    Left[i] = convertNumber(0, i);
    Right[i] = convertNumber(1, i);
  }
  if (!basisTransition()) {
    printf("-1\n");
    return;
  }
  if (!cornerCase()) {
    printf("Alex\n");
    return;
  }
  printSol();
}
int main() {
  Read();
  Solve();
  return 0;
}

### Prompt

Generate 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;
const int NMax = 10005;
const int lgValMax = 33;
int N;
int X[NMax], Y[NMax];
int A[2][NMax][lgValMax];
int first, Line[2][NMax], Pivot[2][NMax];
bool Use[NMax];
vector<pair<int, int> > Sol[2];
vector<pair<int, int> > Basis;
int Left[NMax], Right[NMax];
void Read() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> X[i];
    Line[0][i] = Line[1][i] = i;
  }
  first = X[1];
  for (int i = 1; i <= N; i++) cin >> Y[i];
}
void fillA(int ind, int line, int val) {
  for (int i = 0; i < 30; i++)
    if (val & (1 << i)) A[ind][line][i + 1] = 1;
}
void buildA(int ind) {
  for (int i = 1; i <= N; i++) {
    fillA(ind, i, X[i]);
  }
}
bool findPivot(int ind, int i, int j) {
  int k;
  for (k = i; k <= N && A[ind][k][j] == 0; k++)
    ;
  if (k == N + 1) {
    return 0;
  }
  if (k != i) {
    swap(A[ind][k], A[ind][i]);
    Sol[ind].push_back(make_pair(i, k));
    Sol[ind].push_back(make_pair(k, i));
    Sol[ind].push_back(make_pair(i, k));
  }
  return 1;
}
void fillOperation(int ind, int l1, int l2) {
  Sol[ind].push_back(make_pair(Line[ind][l2], Line[ind][l1]));
  for (int k = 1; k <= 30; k++) A[ind][l2][k] ^= A[ind][l1][k];
}
void toEF(int ind) {
  int i = 1, j = 1, k;
  while (i <= N && j <= 30) {
    if (!findPivot(ind, i, j)) {
      ++j;
      continue;
    }
    Pivot[ind][j] = i;
    for (int k = i + 1; k <= N; k++) {
      if (A[ind][k][j] == 1) fillOperation(ind, i, k);
    }
    ++i;
    ++j;
  }
}
void toREF(int ind) {
  for (int j = 30; j >= 1; j--) {
    if (Pivot[ind][j] == 0) continue;
    int piv = Pivot[ind][j];
    for (int k = piv - 1; k >= 1; k--)
      if (A[ind][k][j] == 1) fillOperation(ind, piv, k);
  }
}
void toUnit(int ind) {
  buildA(ind);
  toEF(ind);
  toREF(ind);
}
void swapXY() {
  for (int i = 1; i <= N; i++) swap(X[i], Y[i]);
}
void printSol() {
  printf("%d\n", Sol[0].size() + Sol[1].size());
  for (int i = 0; i < Sol[0].size(); i++)
    printf("%d %d\n", Sol[0][i].first, Sol[0][i].second);
  for (int i = Sol[1].size() - 1; i >= 0; i--)
    printf("%d %d\n", Sol[1][i].first, Sol[1][i].second);
}
bool check() {
  for (int i = 0; i < Sol[0].size(); i++) {
    X[Sol[0][i].first] ^= X[Sol[0][i].second];
  }
  for (int i = Sol[1].size() - 1; i >= 0; i--)
    X[Sol[1][i].first] ^= X[Sol[1][i].second];
  for (int i = 1; i <= N; i++)
    if (X[i] != Y[i]) return 0;
  return 1;
}
int convertNumber(int ind, int line) {
  int res = 0, p = 1;
  for (int i = 1; i <= 30; i++, p *= 2) res += A[ind][line][i] * p;
  return res;
}
bool cornerCase() {
  for (int i = 0; i < Basis.size(); i++) {
    X[Basis[i].first] ^= X[Basis[i].second];
  }
  for (int i = 1; i <= N; i++)
    if (X[i] != Y[i]) return 0;
  return 1;
}
bool basisTransition() {
  for (int i = 1; i <= N; i++) {
    X[i] = convertNumber(0, i);
    Y[i] = convertNumber(1, i);
  }
  for (int j = 1; j <= 30; j++) {
    int piv = Pivot[1][j];
    if (piv == 0) continue;
    int b = convertNumber(1, piv), aux = 0, first = 0;
    for (int k = 30; k >= 1; k--)
      if (A[1][piv][k] == 1 && Pivot[0][k] != 0) {
        aux ^= convertNumber(0, Pivot[0][k]), first = Pivot[0][k];
      }
    if (aux != b) return 0;
    for (int k = 1; k <= 30; k++)
      if (A[1][piv][k] == 1 && Pivot[0][k] != 0 && first != Pivot[0][k]) {
        Sol[0].push_back(make_pair(first, Pivot[0][k]));
        Basis.push_back(make_pair(first, Pivot[0][k]));
      }
    Left[first] = b;
  }
  for (int i = 1; i <= N; i++) {
    if (Right[i] == 0) continue;
    for (int j = 1; j <= N; j++)
      if (Right[i] == Left[j] && Use[j] == 0) {
        Use[j] = 1;
        if (i != j) {
          Sol[0].push_back(make_pair(i, j));
          Sol[0].push_back(make_pair(j, i));
          Sol[0].push_back(make_pair(i, j));
          Basis.push_back(make_pair(i, j));
          Basis.push_back(make_pair(j, i));
          Basis.push_back(make_pair(i, j));
          swap(Use[i], Use[j]);
          swap(Left[i], Left[j]);
        }
        break;
      }
  }
  for (int i = 1; i <= N; i++)
    if (Right[i] == 0) {
      Sol[0].push_back(make_pair(i, i));
      Basis.push_back(make_pair(i, i));
    }
  return 1;
}
void Solve() {
  toUnit(0);
  swapXY();
  toUnit(1);
  swapXY();
  for (int i = 1; i <= N; i++) {
    Left[i] = convertNumber(0, i);
    Right[i] = convertNumber(1, i);
  }
  if (!basisTransition()) {
    printf("-1\n");
    return;
  }
  if (!cornerCase()) {
    printf("Alex\n");
    return;
  }
  printSol();
}
int main() {
  Read();
  Solve();
  return 0;
}

```