#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, w = 0;
  char c = getchar();
  while (!isdigit(c)) w |= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  return w ? -x : x;
}
namespace star {
const int maxn = 10009;
int x[maxn], y[maxn], a[33], b[33];
vector<pair<int, int>> u, v;
inline void work() {
  int n, i, j;
  n = read();
  for (int i = 1; i <= n; ++i) {
    x[i] = read();
    for (int j = 29; ~j; --j)
      if (x[i] >> j & 1)
        if (!a[j]) {
          a[j] = i;
          break;
        } else
          x[i] ^= x[a[j]], u.push_back({i, a[j]});
  }
  for (int i = 1; i <= n; ++i) {
    y[i] = read();
    for (int j = 29; ~j; --j)
      if (y[i] >> j & 1)
        if (!b[j]) {
          b[j] = i;
          break;
        } else
          y[i] ^= y[b[j]], v.push_back({i, b[j]});
  }
  for (int i = 29; ~i; --i)
    if (b[i]) {
      y[b[i]] ^= x[a[i]];
      for (int j = i - 1; ~j; --j)
        if (y[b[i]] >> j & 1) y[b[i]] ^= x[a[j]], u.push_back({a[i], a[j]});
      if (y[b[i]]) return (void)puts("-1");
    } else if (a[i])
      u.push_back({a[i], a[i]}), a[i] = 0;
  for (int i = 29; ~i; --i)
    if (b[i] and a[i] != b[i]) {
      u.push_back({a[i], b[i]}), u.push_back({b[i], a[i]}),
          u.push_back({a[i], b[i]});
      for (int j = 29; ~j; --j)
        if (a[j] == b[i]) a[j] = a[i];
    }
  printf("%llu\n", (unsigned long long)(u.size() + v.size()));
  for (auto i : u) printf("%d %d\n", i.first, i.second);
  for (auto it = v.rbegin(); it != v.rend(); ++it)
    printf("%d %d\n", it->first, it->second);
}
}  // namespace star
signed main() {
  star::work();
  return 0;
}
