#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10500;
const int MAXK = 32;
int x[MAXN], y[MAXN];
int tmpx[MAXN], tmpy[MAXN];
int n;
vector<pair<int, int> > st, rev;
int coeff[MAXK][MAXK];
void my_swap(int *arr, int i, int j, vector<pair<int, int> > &write) {
  if (i != j) {
    write.push_back(make_pair(i, j));
    arr[i] ^= arr[j];
    write.push_back(make_pair(j, i));
    arr[j] ^= arr[i];
    write.push_back(make_pair(i, j));
    arr[i] ^= arr[j];
  }
}
void gauss(int *arr, vector<pair<int, int> > &write) {
  int cnt = 0;
  while (true) {
    int ind = cnt;
    for (int i = cnt; i < n; ++i) {
      if (arr[i] > arr[ind]) {
        ind = i;
      }
    }
    if (ind >= n || arr[ind] == 0) {
      break;
    }
    my_swap(arr, cnt, ind, write);
    int cur_bit = 29;
    while (((1 << cur_bit) & arr[cnt]) == 0) {
      --cur_bit;
    }
    for (int j = cnt + 1; j < n; ++j) {
      if (((1 << cur_bit) & arr[j]) != 0) {
        arr[j] ^= arr[cnt];
        write.push_back(make_pair(j, cnt));
      }
    }
    ++cnt;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    tmpx[i] = x[i];
  }
  for (int j = 0; j < n; ++j) {
    cin >> y[j];
    tmpy[j] = y[j];
  }
  st.clear();
  rev.clear();
  gauss(x, st);
  gauss(y, rev);
  int k = 0, l = 0;
  for (int i = 0; i < n; ++i) {
    if (x[i] != 0) {
      k = i + 1;
    }
    if (y[i] != 0) {
      l = i + 1;
    }
  }
  bool ok = true;
  for (int i = 0; i < l && ok; ++i) {
    int cur_num = y[i];
    for (int j = 0; j < k; ++j) {
      coeff[i][j] = 0;
      int cur_bit = 29;
      while (((1 << cur_bit) & x[j]) == 0) {
        --cur_bit;
      }
      if (((1 << cur_bit) & cur_num) != 0) {
        cur_num ^= x[j];
        coeff[i][j] = 1;
      }
    }
    if (cur_num != 0) {
      ok = false;
    }
  }
  if (!ok) {
    puts("-1");
  } else {
    for (int row = 0, col = 0; row < l && col < k;) {
      int ind = row;
      while (ind < l && coeff[ind][col] == 0) {
        ++ind;
      }
      if (ind == l) {
        ++col;
        continue;
      }
      if (ind != row) {
        rev.push_back(make_pair(ind, row));
        rev.push_back(make_pair(row, ind));
        rev.push_back(make_pair(ind, row));
        for (int j = 0; j < k; ++j) {
          swap(coeff[ind][j], coeff[row][j]);
        }
      }
      for (int j = row + 1; j < l; ++j) {
        if (coeff[j][col] == 1) {
          rev.push_back(make_pair(j, row));
          for (int id = 0; id < k; ++id) {
            coeff[j][id] ^= coeff[row][id];
          }
        }
      }
      ++col;
      ++row;
    }
    for (int xpos = 0; xpos < k; ++xpos) {
      for (int ypos = min(xpos, l) - 1; ypos >= 0; --ypos) {
        if (coeff[ypos][xpos]) {
          st.push_back(make_pair(ypos, xpos));
        }
      }
      if (xpos >= l || coeff[xpos][xpos] == 0) {
        st.push_back(make_pair(xpos, xpos));
      }
    }
    cout << st.size() + rev.size() << '\n';
    for (auto mv : st) {
      cout << mv.first + 1 << " " << mv.second + 1 << '\n';
    }
    reverse(rev.begin(), rev.end());
    for (auto mv : rev) {
      cout << mv.first + 1 << " " << mv.second + 1 << '\n';
    }
    cout.flush();
    for (auto mv : st) {
      tmpx[mv.first] ^= tmpx[mv.second];
    }
    for (auto mv : rev) {
      tmpx[mv.first] ^= tmpx[mv.second];
    }
    for (int i = 0; i < n; ++i) {
      assert(tmpx[i] == tmpy[i]);
    }
  }
  return 0;
}

### Prompt

In cpp, your task is to solve 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 MAXN = 10500;
const int MAXK = 32;
int x[MAXN], y[MAXN];
int tmpx[MAXN], tmpy[MAXN];
int n;
vector<pair<int, int> > st, rev;
int coeff[MAXK][MAXK];
void my_swap(int *arr, int i, int j, vector<pair<int, int> > &write) {
  if (i != j) {
    write.push_back(make_pair(i, j));
    arr[i] ^= arr[j];
    write.push_back(make_pair(j, i));
    arr[j] ^= arr[i];
    write.push_back(make_pair(i, j));
    arr[i] ^= arr[j];
  }
}
void gauss(int *arr, vector<pair<int, int> > &write) {
  int cnt = 0;
  while (true) {
    int ind = cnt;
    for (int i = cnt; i < n; ++i) {
      if (arr[i] > arr[ind]) {
        ind = i;
      }
    }
    if (ind >= n || arr[ind] == 0) {
      break;
    }
    my_swap(arr, cnt, ind, write);
    int cur_bit = 29;
    while (((1 << cur_bit) & arr[cnt]) == 0) {
      --cur_bit;
    }
    for (int j = cnt + 1; j < n; ++j) {
      if (((1 << cur_bit) & arr[j]) != 0) {
        arr[j] ^= arr[cnt];
        write.push_back(make_pair(j, cnt));
      }
    }
    ++cnt;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    tmpx[i] = x[i];
  }
  for (int j = 0; j < n; ++j) {
    cin >> y[j];
    tmpy[j] = y[j];
  }
  st.clear();
  rev.clear();
  gauss(x, st);
  gauss(y, rev);
  int k = 0, l = 0;
  for (int i = 0; i < n; ++i) {
    if (x[i] != 0) {
      k = i + 1;
    }
    if (y[i] != 0) {
      l = i + 1;
    }
  }
  bool ok = true;
  for (int i = 0; i < l && ok; ++i) {
    int cur_num = y[i];
    for (int j = 0; j < k; ++j) {
      coeff[i][j] = 0;
      int cur_bit = 29;
      while (((1 << cur_bit) & x[j]) == 0) {
        --cur_bit;
      }
      if (((1 << cur_bit) & cur_num) != 0) {
        cur_num ^= x[j];
        coeff[i][j] = 1;
      }
    }
    if (cur_num != 0) {
      ok = false;
    }
  }
  if (!ok) {
    puts("-1");
  } else {
    for (int row = 0, col = 0; row < l && col < k;) {
      int ind = row;
      while (ind < l && coeff[ind][col] == 0) {
        ++ind;
      }
      if (ind == l) {
        ++col;
        continue;
      }
      if (ind != row) {
        rev.push_back(make_pair(ind, row));
        rev.push_back(make_pair(row, ind));
        rev.push_back(make_pair(ind, row));
        for (int j = 0; j < k; ++j) {
          swap(coeff[ind][j], coeff[row][j]);
        }
      }
      for (int j = row + 1; j < l; ++j) {
        if (coeff[j][col] == 1) {
          rev.push_back(make_pair(j, row));
          for (int id = 0; id < k; ++id) {
            coeff[j][id] ^= coeff[row][id];
          }
        }
      }
      ++col;
      ++row;
    }
    for (int xpos = 0; xpos < k; ++xpos) {
      for (int ypos = min(xpos, l) - 1; ypos >= 0; --ypos) {
        if (coeff[ypos][xpos]) {
          st.push_back(make_pair(ypos, xpos));
        }
      }
      if (xpos >= l || coeff[xpos][xpos] == 0) {
        st.push_back(make_pair(xpos, xpos));
      }
    }
    cout << st.size() + rev.size() << '\n';
    for (auto mv : st) {
      cout << mv.first + 1 << " " << mv.second + 1 << '\n';
    }
    reverse(rev.begin(), rev.end());
    for (auto mv : rev) {
      cout << mv.first + 1 << " " << mv.second + 1 << '\n';
    }
    cout.flush();
    for (auto mv : st) {
      tmpx[mv.first] ^= tmpx[mv.second];
    }
    for (auto mv : rev) {
      tmpx[mv.first] ^= tmpx[mv.second];
    }
    for (int i = 0; i < n; ++i) {
      assert(tmpx[i] == tmpy[i]);
    }
  }
  return 0;
}

```