#include <bits/stdc++.h>
using namespace std;
void do_xor(int* a, int x, int y, vector<pair<int, int> >& v) {
  a[x] ^= a[y];
  v.emplace_back(x, y);
}
void do_swap(int* a, int x, int y, vector<pair<int, int> >& v) {
  do_xor(a, x, y, v);
  do_xor(a, y, x, v);
  do_xor(a, x, y, v);
}
int n;
vector<pair<int, int> > solve(int* a) {
  vector<pair<int, int> > ret;
  for (int i = 29, j = 1, k; i >= 0; --i) {
    for (k = j; k <= n && !(a[k] >> i & 1); ++k)
      ;
    if (k > n) continue;
    if (k != j) do_swap(a, k, j, ret);
    for (k = 1; k <= n; ++k)
      if ((a[k] >> i & 1) && (k != j)) do_xor(a, k, j, ret);
    ++j;
  }
  return ret;
}
const int N = 10010;
int a[N], b[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) cin >> b[i];
  auto u = solve(a), v = solve(b);
  for (int i = 1, j, k = 29; i <= n && a[i]; ++i) {
    for (; !(a[i] >> k & 1); --k)
      ;
    for (j = 1; j <= 30 && j <= n; ++j)
      if ((a[j] ^ b[j]) >> k & 1) do_xor(a, j, i, u);
  }
  for (int i = 1; i <= n; ++i)
    if (a[i] != b[i]) {
      cout << "-1\n";
      return 0;
    }
  cout << (u.size() + v.size()) << '\n';
  reverse(v.begin(), v.end());
  for (auto i : u) cout << i.first << ' ' << i.second << '\n';
  for (auto i : v) cout << i.first << ' ' << i.second << '\n';
  return 0;
}
