#include <bits/stdc++.h>
using namespace std;
int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
long long fastMin(long long x, long long y) {
  return (((y - x) >> (64 - 1)) & (x ^ y)) ^ x;
}
long long fastMax(long long x, long long y) {
  return (((y - x) >> (64 - 1)) & (x ^ y)) ^ y;
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
vector<pair<int, int> > oper;
int seisoku(vector<int>& v) {
  oper.clear();
  int cnt = 0;
  bool used[((int)1e4)] = {};
  for (int i = 29; i >= 0; i--) {
    int ch = -1;
    for (int j = 0; j < (((int)(v).size())); j++)
      if (v[j] & (1 << i)) {
        if (j < cnt) continue;
        ch = j;
        break;
      }
    if (ch == -1) continue;
    if (cnt != ch) {
      swap(v[cnt], v[ch]);
      oper.emplace_back(cnt, ch);
      oper.emplace_back(ch, cnt);
      oper.emplace_back(cnt, ch);
    }
    for (int j = 0; j < (((int)(v).size())); j++) {
      if (j == cnt) continue;
      if (v[j] & (1 << i)) {
        v[j] ^= v[cnt];
        oper.emplace_back(j, cnt);
      }
    }
    cnt++;
  }
  return cnt;
}
bool check(vector<int> se, vector<int> y) {
  for (auto s : se) {
    int mlb = -1;
    for (int i = 29; i >= 0; i--)
      if (s & (1 << i)) {
        mlb = i;
        break;
      }
    for (auto& v : y) {
      if (v & (1 << mlb)) {
        v ^= s;
      }
    }
  }
  for (auto v : y)
    if (v != 0) return false;
  return true;
}
void HHH(vector<int>& x, vector<pair<int, int> >& p) {
  for (int i = 0; i < (((int)(p).size())); i++) {
    auto a = p[i];
    x[a.first] ^= x[a.second];
    printf("x[%d] ^= x[%d]\n", a.first + 1, a.second + 1);
    for (auto d : x) printf("%d ", d);
    puts("");
  }
}
void asssert(vector<int>& x, vector<int>& y, vector<pair<int, int> >& ans) {
  HHH(x, ans);
  for (int i = 0; i < (((int)(x).size())); i++)
    if (x[i] != y[i]) {
      printf("x[%d](= %d) != y[%d] (= %d)\n", i, x[i], i, y[i]);
      assert(false);
    }
}
int n;
int main() {
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < (n); i++) cin >> x[i];
  for (int i = 0; i < (n); i++) cin >> y[i];
  vector<int> _x_ = x, _y_ = y;
  int x_secnt = seisoku(x);
  vector<pair<int, int> > fst = oper;
  vector<int> xse;
  for (int i = 0; i < (x_secnt); i++) xse.push_back(x[i]);
  bool b = check(xse, y);
  if (!b) {
    puts("-1");
    return 0;
  }
  int y_secnt = seisoku(y);
  vector<pair<int, int> > last = oper;
  reverse(last.begin(), last.end());
  vector<int> yse;
  for (int i = 0; i < (y_secnt); i++) yse.push_back(y[i]);
  vector<pair<int, int> > middle;
  for (int i = 0; i < (x_secnt); i++) {
    int mlb = -1;
    for (int j = 29; j >= 0; j--)
      if (xse[i] & (1 << j)) {
        mlb = j;
        break;
      }
    bool use = false;
    for (int j = 0; j < (i + 1); j++) {
      if (j >= y_secnt) break;
      if (yse[j] & (1 << mlb)) use = true;
    }
    if (!use) {
      middle.emplace_back(i, i);
      xse[i] ^= xse[i];
      continue;
    }
    for (int j = 0; j < (i); j++) {
      if (j >= y_secnt) break;
      if (yse[j] & (1 << mlb)) {
        middle.emplace_back(j, i);
        xse[j] ^= xse[i];
      }
    }
    if (i < y_secnt && (yse[i] & (1 << mlb)) == 0) {
      middle.emplace_back(i, i);
      xse[i] ^= xse[i];
    }
  }
  for (int i = y_secnt; i < x_secnt; i++) {
    middle.emplace_back(i, i);
    xse[i] ^= xse[i];
  }
  vector<pair<int, int> > ans;
  for (auto a : fst) ans.push_back(a);
  for (auto a : middle) ans.push_back(a);
  for (auto a : last) ans.push_back(a);
  printf("%d\n", ((int)(ans).size()));
  for (auto a : ans) printf("%d %d\n", a.first + 1, a.second + 1);
  return 0;
}

### 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;
int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
long long fastMin(long long x, long long y) {
  return (((y - x) >> (64 - 1)) & (x ^ y)) ^ x;
}
long long fastMax(long long x, long long y) {
  return (((y - x) >> (64 - 1)) & (x ^ y)) ^ y;
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
vector<pair<int, int> > oper;
int seisoku(vector<int>& v) {
  oper.clear();
  int cnt = 0;
  bool used[((int)1e4)] = {};
  for (int i = 29; i >= 0; i--) {
    int ch = -1;
    for (int j = 0; j < (((int)(v).size())); j++)
      if (v[j] & (1 << i)) {
        if (j < cnt) continue;
        ch = j;
        break;
      }
    if (ch == -1) continue;
    if (cnt != ch) {
      swap(v[cnt], v[ch]);
      oper.emplace_back(cnt, ch);
      oper.emplace_back(ch, cnt);
      oper.emplace_back(cnt, ch);
    }
    for (int j = 0; j < (((int)(v).size())); j++) {
      if (j == cnt) continue;
      if (v[j] & (1 << i)) {
        v[j] ^= v[cnt];
        oper.emplace_back(j, cnt);
      }
    }
    cnt++;
  }
  return cnt;
}
bool check(vector<int> se, vector<int> y) {
  for (auto s : se) {
    int mlb = -1;
    for (int i = 29; i >= 0; i--)
      if (s & (1 << i)) {
        mlb = i;
        break;
      }
    for (auto& v : y) {
      if (v & (1 << mlb)) {
        v ^= s;
      }
    }
  }
  for (auto v : y)
    if (v != 0) return false;
  return true;
}
void HHH(vector<int>& x, vector<pair<int, int> >& p) {
  for (int i = 0; i < (((int)(p).size())); i++) {
    auto a = p[i];
    x[a.first] ^= x[a.second];
    printf("x[%d] ^= x[%d]\n", a.first + 1, a.second + 1);
    for (auto d : x) printf("%d ", d);
    puts("");
  }
}
void asssert(vector<int>& x, vector<int>& y, vector<pair<int, int> >& ans) {
  HHH(x, ans);
  for (int i = 0; i < (((int)(x).size())); i++)
    if (x[i] != y[i]) {
      printf("x[%d](= %d) != y[%d] (= %d)\n", i, x[i], i, y[i]);
      assert(false);
    }
}
int n;
int main() {
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < (n); i++) cin >> x[i];
  for (int i = 0; i < (n); i++) cin >> y[i];
  vector<int> _x_ = x, _y_ = y;
  int x_secnt = seisoku(x);
  vector<pair<int, int> > fst = oper;
  vector<int> xse;
  for (int i = 0; i < (x_secnt); i++) xse.push_back(x[i]);
  bool b = check(xse, y);
  if (!b) {
    puts("-1");
    return 0;
  }
  int y_secnt = seisoku(y);
  vector<pair<int, int> > last = oper;
  reverse(last.begin(), last.end());
  vector<int> yse;
  for (int i = 0; i < (y_secnt); i++) yse.push_back(y[i]);
  vector<pair<int, int> > middle;
  for (int i = 0; i < (x_secnt); i++) {
    int mlb = -1;
    for (int j = 29; j >= 0; j--)
      if (xse[i] & (1 << j)) {
        mlb = j;
        break;
      }
    bool use = false;
    for (int j = 0; j < (i + 1); j++) {
      if (j >= y_secnt) break;
      if (yse[j] & (1 << mlb)) use = true;
    }
    if (!use) {
      middle.emplace_back(i, i);
      xse[i] ^= xse[i];
      continue;
    }
    for (int j = 0; j < (i); j++) {
      if (j >= y_secnt) break;
      if (yse[j] & (1 << mlb)) {
        middle.emplace_back(j, i);
        xse[j] ^= xse[i];
      }
    }
    if (i < y_secnt && (yse[i] & (1 << mlb)) == 0) {
      middle.emplace_back(i, i);
      xse[i] ^= xse[i];
    }
  }
  for (int i = y_secnt; i < x_secnt; i++) {
    middle.emplace_back(i, i);
    xse[i] ^= xse[i];
  }
  vector<pair<int, int> > ans;
  for (auto a : fst) ans.push_back(a);
  for (auto a : middle) ans.push_back(a);
  for (auto a : last) ans.push_back(a);
  printf("%d\n", ((int)(ans).size()));
  for (auto a : ans) printf("%d %d\n", a.first + 1, a.second + 1);
  return 0;
}

```