#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
void move(int *x, int i, int j, int &nret, int ret[1000000][2]) {
  ret[nret][0] = i, ret[nret][1] = j, ++nret, x[i] ^= x[j];
}
void swap(int *x, int i, int j, int &nret, int ret[1000000][2]) {
  move(x, i, j, nret, ret);
  move(x, j, i, nret, ret);
  move(x, i, j, nret, ret);
}
void gaussjord(int n, int *x, int &nret, int ret[1000000][2]) {
  for (int i = (0); i < (n); ++i) {
    {
      int best = i;
      for (int j = (i + 1); j < (n); ++j)
        if (x[j] > x[best]) best = j;
      if (best != i) swap(x, i, best, nret, ret);
    }
    for (int j = (i + 1); j < (n); ++j)
      if ((x[i] ^ x[j]) < x[j]) move(x, j, i, nret, ret);
  }
  for (int i = n - 1; i >= 0; --i)
    if (x[i] != 0) {
      for (int j = (0); j < (i); ++j)
        if ((x[i] ^ x[j]) < x[j]) move(x, j, i, nret, ret);
    }
}
int n;
int s[10000];
int t[10000];
int ret1[1000000][2], nret1;
int ret2[1000000][2], nret2;
int ret[1000000][2], nret;
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &s[i]);
  for (int i = (0); i < (n); ++i) scanf("%d", &t[i]);
  nret1 = nret2 = 0;
  gaussjord(n, s, nret1, ret1);
  gaussjord(n, t, nret2, ret2);
  for (int i = (0); i < (n); ++i) {
    for (int j = (i); j < (n); ++j) {
      if (s[j] == 0) break;
      bool have = (s[i] ^ s[j]) < s[i];
      bool want = (t[i] ^ s[j]) < t[i];
      if (have != want) move(s, i, j, nret1, ret1);
    }
  }
  for (int i = (0); i < (n); ++i)
    if (s[i] != t[i]) {
      printf("-1\n");
      return;
    }
  printf("%d\n", nret1 + nret2);
  for (int i = (0); i < (nret1); ++i)
    printf("%d %d\n", ret1[i][0] + 1, ret1[i][1] + 1);
  for (int i = nret2 - 1; i >= 0; --i)
    printf("%d %d\n", ret2[i][0] + 1, ret2[i][1] + 1);
}
int main() {
  run();
  return 0;
}
