#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > f, s;
vector<int> a, b;
int n;
void make(vector<pair<int, int> > &v, vector<int> &a, int i, int j) {
  v.push_back(make_pair(i + 1, j + 1));
  a[i] ^= a[j];
}
void gauss(vector<int> &mas, vector<pair<int, int> > &mov) {
  int r = 0;
  for (int bit = 30; bit >= 0; bit--) {
    for (int i = r; i < n; i++) {
      if (mas[i] & (1 << bit)) {
        if (i != r) {
          make(mov, mas, r, i);
          make(mov, mas, i, r);
          make(mov, mas, r, i);
        }
        for (int j = 0; j < n; ++j) {
          if (j == r) continue;
          if (!((mas[j] ^ mas[r]) & (1 << bit))) make(mov, mas, j, r);
        }
        r++;
        break;
      }
    }
  }
}
int gethigh(int val) {
  if (val == 0) return -1;
  int ans = 30;
  while (ans && !(val & (1 << ans))) ans--;
  return ans;
}
void swap(vector<pair<int, int> > &v, vector<int> &a, int i, int j) {
  make(v, a, i, j);
  make(v, a, j, i);
  make(v, a, i, j);
}
int main() {
  scanf("%d", &n);
  a.resize(n), b.resize(n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
  gauss(a, f);
  gauss(b, s);
  int to = min(31, n);
  for (int i = 0; i < to; i++) {
    if (b[i] == 0) {
      make(f, a, i, i);
      continue;
    }
    int bit = gethigh(b[i]);
    if (gethigh(a[i]) != bit) {
      int ind = -1;
      for (int iter = 0; iter < to; ++iter)
        if (gethigh(a[iter]) == bit) ind = iter;
      if (ind == -1) break;
      ::swap(f, a, i, ind);
    }
    for (int j = bit - 1; j >= 0; j--) {
      if ((a[i] ^ b[i]) & (1 << j)) {
        for (int iter = i + 1; iter < to; iter++) {
          int h = gethigh(a[iter]);
          if (h == j) {
            make(f, a, i, iter);
            break;
          }
        }
      }
    }
  }
  for (int i = 0; i < ((int)a.size()); ++i)
    if (a[i] != b[i]) {
      printf("-1\n");
      return 0;
    }
  printf("%d\n", ((int)s.size()) + ((int)f.size()));
  reverse(s.begin(), s.end());
  for (int i = 0; i < ((int)f.size()); ++i)
    printf("%d %d\n", f[i].first, f[i].second);
  for (int i = 0; i < ((int)s.size()); ++i)
    printf("%d %d\n", s[i].first, s[i].second);
  return 0;
}
