#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int inf = 1000000007;
const long long linf = 1000000000000000000LL;
const unsigned long long ulinf = (1ULL << 63) - 10ULL;
const double eps = 0.000001;
const double pi = 3.14159265358979323846;
template <class T>
T abs(T a) {
  return a >= 0 ? a : -a;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T mod(T a, T b) {
  return (a % b + b) % b;
}
template <class T>
T lowbit(T x) {
  return x & -x;
}
long long addmod(long long a, long long b, long long c) {
  return ((a + b) % c + c) % c;
}
long long mulmod(long long a, long long b, long long c) {
  if (b == 0LL) return 0LL;
  long long ret = mulmod(a, b >> 1, c);
  ret = (ret + ret) % c;
  if (b & 1LL) ret = (ret + a) % c;
  return ret;
}
long long powmod(long long a, long long b, long long c) {
  if (b == 0LL) return 1LL;
  long long ret = powmod(a, b >> 1, c);
  ret = ret * ret % c;
  if (b & 1LL) ret = ret * a % c;
  return ret;
}
long long modinv(long long a, long long b) { return powmod(a, b - 2LL, b); }
template <class T>
void maxe(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void mine(T &a, T b) {
  if (a > b) a = b;
}
int iszero(double a) { return abs(a) <= eps; }
template <class T>
void geti(T &a) {
  a = 0;
  T b = 1;
  char c = getchar();
  if (c == '-')
    b = -1;
  else
    a = c - 48;
  while ((c = getchar()) != ' ' && c != '\n') a = a * 10 + c - 48;
  a *= b;
}
void fileio_in_out() {
  freopen("hack.in", "r", stdin);
  freopen("hack.out", "w", stdout);
}
void fileio_txt() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
const int N = 22222;
const int M = 100010;
const int K = 33;
const long long md = inf;
int test;
int n, m, k, ans;
int a[N], b[N];
vector<pair<int, int> > aa;
stack<pair<int, int> > stk;
int id[33];
int choose[N];
void turn(int x, int y) {
  a[x] ^= a[y];
  aa.push_back(make_pair(x, y));
}
void swa(int x, int y) {
  turn(x, y);
  turn(y, x);
  turn(x, y);
}
int getans() {
  for (int bit = 30; bit >= 0; bit--) {
    id[bit] = -1;
    for (int i = 1; i <= n; i++) {
      if (choose[i]) continue;
      if (a[i] & (1 << bit)) {
        if (id[bit] == -1) {
          id[bit] = i;
          choose[i] = 1;
        } else
          turn(i, id[bit]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (choose[i]) continue;
    for (int bit = 30; bit >= 0; bit--)
      if ((a[i] ^ b[i]) & (1 << bit)) {
        if (id[bit] == -1) return 0;
        turn(i, id[bit]);
      }
  }
  for (int maxbit = 30; maxbit >= 0; maxbit--) {
    for (int i = 0; i <= maxbit; i++) {
      if (id[i] == -1) continue;
      for (int j = i + 1; j <= maxbit; j++) {
        if (id[j] == -1) continue;
        if (b[id[i]] > b[id[j]]) {
          swap(id[i], id[j]);
          swa(id[i], id[j]);
        }
      }
    }
    for (int i = maxbit; i >= 0; i--)
      if ((a[id[maxbit]] ^ b[id[maxbit]]) & (1 << i)) {
        if (id[i] == -1) return 0;
        turn(id[maxbit], id[i]);
      }
    for (int i = 0; i < maxbit; i++)
      if (b[id[i]] & (1 << maxbit)) {
        stk.push(make_pair(id[i], id[maxbit]));
        b[id[i]] ^= b[id[maxbit]];
      }
  }
  while (!stk.empty()) {
    pair<int, int> tp = stk.top();
    stk.pop();
    aa.push_back(tp);
  }
  return aa.size();
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  ans = getans();
  if (ans) {
    printf("%d\n", ans);
    for (int i = 0; i < ans; i++) printf("%d %d\n", aa[i].first, aa[i].second);
  } else
    puts("-1");
  return 0;
}

### Prompt

Please formulate 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>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int inf = 1000000007;
const long long linf = 1000000000000000000LL;
const unsigned long long ulinf = (1ULL << 63) - 10ULL;
const double eps = 0.000001;
const double pi = 3.14159265358979323846;
template <class T>
T abs(T a) {
  return a >= 0 ? a : -a;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T mod(T a, T b) {
  return (a % b + b) % b;
}
template <class T>
T lowbit(T x) {
  return x & -x;
}
long long addmod(long long a, long long b, long long c) {
  return ((a + b) % c + c) % c;
}
long long mulmod(long long a, long long b, long long c) {
  if (b == 0LL) return 0LL;
  long long ret = mulmod(a, b >> 1, c);
  ret = (ret + ret) % c;
  if (b & 1LL) ret = (ret + a) % c;
  return ret;
}
long long powmod(long long a, long long b, long long c) {
  if (b == 0LL) return 1LL;
  long long ret = powmod(a, b >> 1, c);
  ret = ret * ret % c;
  if (b & 1LL) ret = ret * a % c;
  return ret;
}
long long modinv(long long a, long long b) { return powmod(a, b - 2LL, b); }
template <class T>
void maxe(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void mine(T &a, T b) {
  if (a > b) a = b;
}
int iszero(double a) { return abs(a) <= eps; }
template <class T>
void geti(T &a) {
  a = 0;
  T b = 1;
  char c = getchar();
  if (c == '-')
    b = -1;
  else
    a = c - 48;
  while ((c = getchar()) != ' ' && c != '\n') a = a * 10 + c - 48;
  a *= b;
}
void fileio_in_out() {
  freopen("hack.in", "r", stdin);
  freopen("hack.out", "w", stdout);
}
void fileio_txt() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
const int N = 22222;
const int M = 100010;
const int K = 33;
const long long md = inf;
int test;
int n, m, k, ans;
int a[N], b[N];
vector<pair<int, int> > aa;
stack<pair<int, int> > stk;
int id[33];
int choose[N];
void turn(int x, int y) {
  a[x] ^= a[y];
  aa.push_back(make_pair(x, y));
}
void swa(int x, int y) {
  turn(x, y);
  turn(y, x);
  turn(x, y);
}
int getans() {
  for (int bit = 30; bit >= 0; bit--) {
    id[bit] = -1;
    for (int i = 1; i <= n; i++) {
      if (choose[i]) continue;
      if (a[i] & (1 << bit)) {
        if (id[bit] == -1) {
          id[bit] = i;
          choose[i] = 1;
        } else
          turn(i, id[bit]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (choose[i]) continue;
    for (int bit = 30; bit >= 0; bit--)
      if ((a[i] ^ b[i]) & (1 << bit)) {
        if (id[bit] == -1) return 0;
        turn(i, id[bit]);
      }
  }
  for (int maxbit = 30; maxbit >= 0; maxbit--) {
    for (int i = 0; i <= maxbit; i++) {
      if (id[i] == -1) continue;
      for (int j = i + 1; j <= maxbit; j++) {
        if (id[j] == -1) continue;
        if (b[id[i]] > b[id[j]]) {
          swap(id[i], id[j]);
          swa(id[i], id[j]);
        }
      }
    }
    for (int i = maxbit; i >= 0; i--)
      if ((a[id[maxbit]] ^ b[id[maxbit]]) & (1 << i)) {
        if (id[i] == -1) return 0;
        turn(id[maxbit], id[i]);
      }
    for (int i = 0; i < maxbit; i++)
      if (b[id[i]] & (1 << maxbit)) {
        stk.push(make_pair(id[i], id[maxbit]));
        b[id[i]] ^= b[id[maxbit]];
      }
  }
  while (!stk.empty()) {
    pair<int, int> tp = stk.top();
    stk.pop();
    aa.push_back(tp);
  }
  return aa.size();
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  ans = getans();
  if (ans) {
    printf("%d\n", ans);
    for (int i = 0; i < ans; i++) printf("%d %d\n", aa[i].first, aa[i].second);
  } else
    puts("-1");
  return 0;
}

```