#include <bits/stdc++.h>
using namespace std;
int n, m = 30;
int x[10005];
int y[10005];
vector<pair<int, int> > ansX;
vector<pair<int, int> > ansY;
void gauss(int v[], vector<pair<int, int> > &ans) {
  int cur = 0;
  for (int i = 0; i < m; ++i) {
    int idx = -1;
    for (int j = cur; j < n; ++j)
      if (v[j] >> i & 1) {
        idx = j;
        break;
      }
    if (idx == -1) continue;
    if (cur != idx) {
      v[cur] ^= v[idx], ans.push_back(make_pair(cur, idx));
      v[idx] ^= v[cur], ans.push_back(make_pair(idx, cur));
      v[cur] ^= v[idx], ans.push_back(make_pair(cur, idx));
    }
    for (int k = 0; k < n; ++k)
      if (k != cur && (v[k] >> i & 1)) {
        v[k] ^= v[cur], ans.push_back(make_pair(k, cur));
      }
    cur++;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", x + i);
  for (int i = 0; i < n; ++i) scanf("%d", y + i);
  gauss(x, ansX), gauss(y, ansY);
  for (int i = 0; i < m; ++i) {
    int bit = -1;
    for (int j = 0; j < m; ++j)
      if (x[i] >> j & 1) {
        bit = j;
        break;
      }
    if (bit == -1) continue;
    for (int j = 0; j < m; ++j)
      if ((x[j] >> bit & 1) ^ (y[j] >> bit & 1) & 1) {
        x[j] ^= x[i], ansX.push_back(make_pair(j, i));
      }
  }
  for (int i = 0; i < n; ++i)
    if (x[i] != y[i]) {
      printf("-1");
      return 0;
    }
  printf("%d\n", ansX.size() + ansY.size());
  for (int i = 0; i < ansX.size(); ++i)
    printf("%d %d\n", ansX[i].first + 1, ansX[i].second + 1);
  for (int i = (int)ansY.size() - 1; i >= 0; --i)
    printf("%d %d\n", ansY[i].first + 1, ansY[i].second + 1);
}
