#include <bits/stdc++.h>
using namespace std;
const size_t MAX_N = 1e4 + 5;
vector<pair<int, int> > res;
int a[MAX_N], b[MAX_N], n;
inline void add(int *a, int i, int j) {
  a[i] ^= a[j];
  res.emplace_back(i + 1, j + 1);
}
void work(int *a) {
  for (int i = 30, st = 0; i >= 0; --i)
    for (int j = st; j < n; ++j)
      if (a[j] >> i & 1) {
        if (j != st) {
          add(a, j, st);
          add(a, st, j);
          add(a, j, st);
        }
        for (int k = 0; k < n; ++k)
          if (k != st && (a[k] >> i & 1)) add(a, k, st);
        ++st;
        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);
  vector<pair<int, int> > resa, resb;
  work(a);
  resa.swap(res);
  work(b);
  resb.swap(res);
  res.swap(resa);
  for (int i = 0; i < n; ++i)
    if (a[i]) {
      int bit = 30;
      while (!(a[i] >> bit & 1)) --bit;
      for (int j = 0; j <= 30 && j < n; ++j)
        if ((a[j] ^ b[j]) >> bit & 1) add(a, j, i);
    }
  res.insert(res.end(), resb.rbegin(), resb.rend());
  for (int i = 0; i < n; ++i)
    if (a[i] != b[i]) return puts("-1"), 0;
  printf("%lu\n", res.size());
  for (pair<int, int> sol : res) printf("%d %d\n", sol.first, sol.second);
  return 0;
}
