#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
int ary[10005];
int bry[10005];
vector<pair<int, int> > ans;
int pivot[31], pid[31];
int pivot2[31], pid2[31];
bool vis[10005];
void solve(int n, int a[]) {
  for (int i = 0; i < 31; ++i) pid[i] = -1;
  for (int k = 0; k < n; ++k) {
    int v = a[k];
    for (int i = 31 - 1; i >= 0; --i) {
      if (pid[i] == -1) continue;
      if (v & (1 << i)) v ^= pivot[i], ans.push_back(make_pair(k, pid[i]));
    }
    if (v == 0) continue;
    for (int i = 31 - 1; i >= 0; --i) {
      if (v & (1 << i)) {
        assert(pid[i] == -1);
        pivot[i] = v, pid[i] = k;
        for (int j = 0; j < 31; ++j)
          if (pid[j] != -1 and i != j and pivot[j] & (1 << i))
            pivot[j] ^= pivot[i], ans.push_back(make_pair(pid[j], pid[i]));
        break;
      }
    }
  }
}
bool solve3(vector<pair<int, int> > candi);
bool solve2(int n, int a[]) {
  for (int k = 0; k < n; ++k) {
    if (vis[k]) continue;
    int v = a[k];
    for (int i = 31 - 1; i >= 0; --i) {
      if (pid[i] == -1) continue;
      if (v & (1 << i)) v ^= pivot[i], ans.push_back(make_pair(k, pid[i]));
    }
    if (v != 0) return false;
  }
  vector<pair<int, int> > candi;
  for (int i = 31 - 1; i >= 0; --i)
    if (pid[i] != -1) candi.push_back(make_pair(a[pid[i]], pid[i]));
  return solve3(candi);
}
bool solve3(vector<pair<int, int> > candi) {
  vector<pair<int, int> > buf;
  for (int i = 0; i < 31; ++i) pid2[i] = -1;
  for (const auto &p : candi) {
    int k = p.second;
    int v = p.first;
    for (int i = 31 - 1; i >= 0; --i) {
      if (pid2[i] == -1) continue;
      if (v & (1 << i)) v ^= pivot2[i], buf.push_back(make_pair(k, pid2[i]));
    }
    if (v == 0) continue;
    for (int i = 31 - 1; i >= 0; --i) {
      if (v & (1 << i)) {
        assert(pid2[i] == -1);
        pivot2[i] = v, pid2[i] = k;
        for (int j = 0; j < 31; ++j)
          if (pid2[j] != -1 and i != j and pivot2[j] & (1 << i))
            pivot2[j] ^= pivot2[i], buf.push_back(make_pair(pid2[j], pid2[i]));
        break;
      }
    }
  }
  for (int i = 31 - 1; i >= 0; --i) {
    int a = pid[i];
    int b = pid2[i];
    if (a == -1 and b == -1) continue;
    if (a == -1 and b != -1)
      return false;
    else if (a != -1 and b == -1)
      ans.push_back(make_pair(a, a));
    else {
      int d = pivot[i] ^ pivot2[i];
      for (int j = i - 1; j >= 0; --j)
        if (pid[j] != -1 and d & (1 << j))
          d ^= pivot[j], ans.push_back(make_pair(pid[i], pid[j]));
      if (d != 0) return false;
      if (a == b) continue;
      ans.push_back(make_pair(pid[i], b));
      ans.push_back(make_pair(b, pid[i]));
      ans.push_back(make_pair(pid[i], b));
      for (int j = 0; j < 31; ++j)
        if (pid[j] == b) {
          swap(pid[i], pid[j]);
          break;
        }
    }
  }
  reverse((buf).begin(), (buf).end());
  for (const auto &p : buf) ans.push_back(p);
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &ary[i]);
  solve(n, ary);
  for (int i = 0; i < 31; ++i)
    if (pid[i] != -1) vis[pid[i]] = true;
  for (int i = 0; i < n; ++i) scanf("%d", &bry[i]);
  bool posi = solve2(n, bry);
  if (not posi)
    printf("-1");
  else {
    printf("%d\n", ((int)(ans).size()));
    for (const auto &p : ans) printf("%d %d\n", p.first + 1, p.second + 1);
  }
}
