#include <bits/stdc++.h>
using namespace std;
const int bits = 40;
bool success;
vector<int> toVector(int x) {
  vector<int> transformed;
  for (int i = 0; i < bits; ++i) {
    transformed.push_back(x % 2);
    x /= 2;
  }
  return transformed;
}
void addTo(vector<int> &v1, vector<int> &v2) {
  for (int i = 0; i < v1.size(); ++i) v1[i] = (v1[i] + v2[i]) % 2;
}
vector<int> gauss(vector<vector<int> > &matrix, vector<int> column) {
  success = true;
  int m = matrix.size();
  vector<int> units(m, 0);
  vector<vector<int> > reverseMatrix;
  reverseMatrix.assign(bits, vector<int>(m));
  for (int i = 0; i < bits; ++i)
    for (int j = 0; j < m; ++j) reverseMatrix[i][j] = matrix[j][i];
  int high = -1;
  for (int j = 0; j < m; ++j) {
    int i;
    for (i = high + 1; i < bits; ++i)
      if (reverseMatrix[i][j] != 0) break;
    if (i == bits) continue;
    ++high;
    swap(reverseMatrix[high], reverseMatrix[i]);
    swap(column[i], column[high]);
    for (int ii = 0; ii < bits; ++ii) {
      if (ii == high) continue;
      if (reverseMatrix[ii][j] == 0) continue;
      addTo(reverseMatrix[ii], reverseMatrix[high]);
      column[ii] = (column[ii] + column[high]) % 2;
    }
  }
  for (int i = 0; i < 40; ++i) {
    if (column[i] == 0) continue;
    int j;
    for (j = 0; j < m; ++j)
      if (reverseMatrix[i][j] == 1) break;
    if (j < m)
      units[j] = 1;
    else
      success = false;
  }
  return units;
}
vector<int> gauss(vector<int> &basis, int column) {
  vector<vector<int> > matrix;
  for (size_t i = 0; i < basis.size(); ++i)
    matrix.push_back(toVector(basis[i]));
  vector<int> newColumn = toVector(column);
  return gauss(matrix, newColumn);
}
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; ++i) cin >> x[i];
  for (int i = 0; i < n; ++i) cin >> y[i];
  vector<int> xx = x;
  vector<int> yy = y;
  int col = 0;
  while (col < n && x[col] == 0) ++col;
  if (col == n) {
    int ycol = 0;
    while (ycol < n && y[ycol] == 0) ++ycol;
    if (ycol == n) {
      cout << 0;
      return 0;
    } else {
      cout << -1;
      return 0;
    }
  }
  vector<int> numbers;
  vector<int> basis;
  numbers.push_back(col);
  basis.push_back(x[col]);
  for (int i = col + 1; i < n; ++i) {
    gauss(basis, x[i]);
    if (!success) {
      numbers.push_back(i);
      basis.push_back(x[i]);
    }
  }
  vector<pair<int, int> > answer;
  set<int> basnums;
  for (int i = 0; i < numbers.size(); ++i) {
    basnums.insert(numbers[i]);
  }
  for (int i = 0; i < n; ++i) {
    if (basnums.count(i)) continue;
    answer.push_back(make_pair(i, i));
    vector<int> units = gauss(basis, y[i]);
    if (!success) {
      cout << -1;
      return 0;
    }
    for (int j = 0; j < units.size(); ++j)
      if (units[j]) answer.push_back(make_pair(i, numbers[j]));
  }
  vector<bool> finals(numbers.size(), false);
  for (int it = 0; it < 50; ++it) {
    for (int i = 0; i < numbers.size(); ++i) {
      if (y[numbers[i]] == 0) continue;
      if (finals[i]) continue;
      vector<int> units = gauss(basis, y[numbers[i]]);
      if (!success) {
        cout << -1;
        return 0;
      }
      int place = 0;
      while (place < units.size() && (units[place] == 0 || finals[place]))
        ++place;
      if (place == units.size()) continue;
      if (units[i]) place = i;
      if (i != place) {
        answer.push_back(make_pair(numbers[i], numbers[place]));
        answer.push_back(make_pair(numbers[place], numbers[i]));
        answer.push_back(make_pair(numbers[i], numbers[place]));
        swap(basis[i], basis[place]);
      }
      for (int j = 0; j < units.size(); ++j)
        if (units[j] && j != i && j != place) {
          basis[i] ^= basis[j];
          answer.push_back(make_pair(numbers[i], numbers[j]));
        }
      finals[i] = true;
    }
  }
  for (int i = 0; i < numbers.size(); ++i) {
    if (finals[i]) continue;
    if (y[numbers[i]] == 0) {
      answer.push_back(make_pair(numbers[i], numbers[i]));
      basis[i] = 0;
      continue;
    }
    vector<int> units = gauss(basis, y[numbers[i]]);
    if (!success) {
      cout << -1;
      return 0;
    }
    if (!units[i]) answer.push_back(make_pair(numbers[i], numbers[i]));
    for (int j = 0; j < numbers.size(); ++j) {
      if (j == i || !units[j]) continue;
      answer.push_back(make_pair(numbers[i], numbers[j]));
      basis[i] ^= basis[j];
    }
  }
  cout << answer.size() << "\n";
  for (int i = 0; i < answer.size(); ++i)
    cout << answer[i].first + 1 << " " << answer[i].second + 1 << "\n";
  return 0;
}
