#include <bits/stdc++.h>
using namespace std;
const int MAXN(10000);
int n, a[MAXN], b[MAXN];
vector<pair<int, int> > Aa, Ab;
void Op(int *a, int i, int j, vector<pair<int, int> > &Q) {
  Q.push_back(pair<int, int>(i, j));
  a[i] ^= a[j];
}
void W(int *a, vector<pair<int, int> > &Q) {
  int r = 0;
  for (int i = 30; i >= 0; i--) {
    for (int j = r; j < n; j++)
      if ((a[j] & (1 << i))) {
        if (j != r) {
          Op(a, r, j, Q);
          Op(a, j, r, Q);
          Op(a, r, j, Q);
        }
        for (int k = 0; k < n; k++)
          if (k != r && (a[k] & (1 << i))) Op(a, k, r, Q);
        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]);
  W(a, Aa);
  W(b, Ab);
  for (int i = 0; i <= 30 && i < n; i++) {
    if (a[i] == 0) break;
    int k = 1 << 30;
    while (!(k & a[i])) k >>= 1;
    for (int j = 0; j <= 30 && j < n; j++)
      if (((a[j] ^ b[j]) & k)) Op(a, j, i, Aa);
  }
  int u = 0;
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) u = 1;
  if (u)
    printf("-1\n");
  else {
    printf("%d\n", Aa.size() + Ab.size());
    for (int i = 0; i < Aa.size(); i++)
      printf("%d %d\n", Aa[i].first + 1, Aa[i].second + 1);
    reverse(Ab.begin(), Ab.end());
    for (int i = 0; i < Ab.size(); i++)
      printf("%d %d\n", Ab[i].first + 1, Ab[i].second + 1);
  }
  return 0;
}
