#include <bits/stdc++.h>
using namespace std;
struct __timestamper {};
void make_op(vector<int>& x, vector<pair<int, int>>& ans, int i, int j) {
  x[i] ^= x[j];
  ans.push_back(make_pair(i, j));
}
void make_swap(vector<int>& x, vector<pair<int, int>>& ans, int i, int j) {
  if (i == j) return;
  make_op(x, ans, i, j);
  make_op(x, ans, j, i);
  make_op(x, ans, i, j);
}
int n;
int make_iter(vector<int>& x, vector<pair<int, int>>& ans, int pos) {
  int mid = max_element(x.begin() + pos, x.end()) - x.begin();
  make_swap(x, ans, mid, pos);
  if (x[pos] == 0) return -1;
  int bit = 31 - __builtin_clz(x[pos]);
  for (int j = 0; j < n; j++)
    if (j != pos && (x[j] & (1 << bit))) make_op(x, ans, j, pos);
  return bit;
}
void solve() {
  vector<int> xs(n), ys(n);
  for (int& x : xs) scanf("%d", &x);
  for (int& y : ys) scanf("%d", &y);
  vector<pair<int, int>> ans1, ans2;
  for (int i = 0; i < n; i++) {
    int b1 = make_iter(xs, ans1, i);
    int b2 = make_iter(ys, ans2, i);
    if (b1 == -1 && b2 == -1) break;
    if (b1 == b2) continue;
    if (b2 > b1) {
      printf("-1\n");
      return;
    }
    for (int j = 0; j < i; j++) {
      if (ys[j] & (1 << b1)) make_op(xs, ans1, j, i);
    }
    make_op(xs, ans1, i, i);
    i--;
  }
  if (xs != ys) {
    printf("-1\n");
    return;
  }
  ans1.insert(ans1.end(), ans2.rbegin(), ans2.rend());
  printf("%d\n", ans1.size());
  for (auto x : ans1) printf("%d %d\n", x.first + 1, x.second + 1);
}
int main() {
  while (scanf("%d", &n) == 1) {
    solve();
  }
  return 0;
}
