#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 5;
int n, a[maxn], b[maxn];
pair<int, int> opa[maxn * 20], opb[maxn * 20];
void Swap(int *a, int x, int y, int &cnt, pair<int, int> *op) {
  if (x == y) return;
  op[cnt++] = make_pair(x, y);
  op[cnt++] = make_pair(y, x);
  op[cnt++] = make_pair(x, y);
  swap(a[x], a[y]);
}
void Gauss(int *a, int &cnt, pair<int, int> *op) {
  int r = 0;
  for (int i = 30; i >= 0; --i) {
    for (int j = r; j < n; ++j)
      if (a[j] & (1 << i)) {
        Swap(a, r, j, cnt, op);
        for (int k = 0; k < n; ++k)
          if (k != r && a[k] & (1 << i)) {
            a[k] ^= a[r];
            op[cnt++] = make_pair(k, r);
          }
        ++r;
        break;
      }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 0; i < n; ++i) scanf("%d", b + i);
  int ca = 0, cb = 0;
  Gauss(a, ca, opa);
  Gauss(b, cb, opb);
  for (int i = 0; i < 40 && i < n; i++) {
    int p = 30;
    if (a[i] == 0) continue;
    while ((a[i] & (1 << p)) == 0) p--;
    for (int j = 0; j < 40 && j < n; j++)
      if ((a[j] ^ b[j]) & (1 << p)) {
        opa[ca++] = make_pair(j, i);
        a[j] ^= a[i];
      }
  }
  for (int i = 0; i < n; ++i)
    if (a[i] != b[i]) return puts("-1");
  printf("%d\n", ca + cb);
  for (int i = 0; i < ca; ++i)
    printf("%d %d\n", opa[i].first + 1, opa[i].second + 1);
  for (int i = cb - 1; i >= 0; --i)
    printf("%d %d\n", opb[i].first + 1, opb[i].second + 1);
  return 0;
}
