#include <bits/stdc++.h>   using namespace std;   const int MAXN = 10101;   const int BIT = 30;   int N;   int arr[MAXN], brr[MAXN];   bool isb[MAXN];   vector<pair<int, int> > vans;   void action(int a, int b) {     arr[b] ^= arr[a];     vans.push_back(make_pair(b + 1, a + 1));   }   void aswap(int a, int b) {     if (a == b) return;     action(a, b);     action(b, a);     action(a, b);   }   void fail() {     cout << -1 << endl;     exit(0);   }   void calc() {     int basis[BIT];     memset((basis), -1, sizeof(basis));     memset((isb), 0, sizeof(isb));     for (int i = 0; i < BIT; i++) {       for (int j = 0; j < N; j++) {         if (isb[j]) continue;         if (arr[j] & (1 << i)) {           basis[i] = j;           isb[j] = true;           break;         }       }       if (basis[i] == -1) continue;       for (int j = 0; j < N; j++) {         if (j == basis[i]) continue;         if (arr[j] & (1 << i)) {           action(basis[i], j);         }       }     }     bool bused[BIT];     memset((bused), 0, sizeof(bused));     for (int i = 0; i < N; i++) {       int x = brr[i];       for (int j = 0; j < BIT; j++) {         if (basis[j] == -1) continue;         if (x & (1 << j)) {           x ^= arr[basis[j]];           if (!bused[j]) {             bused[j] = true;           }         }       }       if (x) fail();     }     for (int i = 0; i < N; i++) {       if (arr[i]) continue;       int x = brr[i];       for (int j = 0; j < BIT; j++) {         if (basis[j] == -1) continue;         if (x & (1 << j)) {           x ^= arr[basis[j]];           action(basis[j], i);         }       }     }     int mat[BIT], mat2[BIT];     memset((mat), 0, sizeof(mat));     memset((mat2), 0, sizeof(mat2));     memset((bused), 0, sizeof(bused));     for (int i = 0; i < BIT; i++) {       if (basis[i] == -1) continue;       mat2[i] = 1 << i;       int x = brr[basis[i]];       for (int j = 0; j < BIT; j++) {         if (basis[j] == -1) continue;         if (x & (1 << j)) {           x ^= arr[basis[j]];           mat[i] ^= 1 << j;         }       }     }     for (int i = 0; i < BIT; i++) {       if (basis[i] == -1) continue;       int pv = -1;       for (int j = 0; j < BIT; j++) {         if (basis[j] == -1) continue;         if (bused[j]) continue;         if (mat[j] & 1 << i) {           pv = j;           bused[j] = true;           break;         }       }       if (pv == -1) continue;       swap(bused[i], bused[pv]);       swap(mat[i], mat[pv]);       swap(mat2[i], mat2[pv]);       for (int j = 0; j < BIT; j++) {         if (basis[j] == -1) continue;         if (j == i) continue;         if (mat[j] & 1 << i) {           mat[j] ^= mat[i];           mat2[j] ^= mat2[i];         }       }     }     for (int i = 0; i < BIT; i++) {       if (basis[i] == -1) continue;       if (!(mat[i] & 1 << i)) {         for (int j = 0; j < BIT; j++) {           if (basis[j] == -1) continue;           if (j == i) continue;           if (mat[j] & 1 << i) action(basis[i], basis[j]);         }         action(basis[i], basis[i]);       }     }     for (int i = 0; i < BIT; i++) {       if (basis[i] == -1) continue;       int pv = -1;       for (int j = i; j < BIT; j++) {         if (basis[j] == -1) continue;         if (mat2[j] & 1 << i) {           pv = j;           break;         }       }       swap(mat2[i], mat2[pv]);       aswap(basis[i], basis[pv]);       for (int j = 0; j < BIT; j++) {         if (basis[j] == -1) continue;         if (j == i) continue;         if (mat2[j] & 1 << i) {           mat2[j] ^= mat2[i];           action(basis[i], basis[j]);         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin >> N;     for (int i = 0; i < N; i++) cin >> arr[i];     for (int i = 0; i < N; i++) cin >> brr[i];     calc();     int A = vans.size();     cout << A <<   n ;     for (__typeof(vans.begin()) it = vans.begin(); it != vans.end(); it++) {       cout << it->first <<     << it->second <<   n ;     }     return 0;   }