/*
⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡎⣿⢾⡿⣿⡆⢸⣽⢻⣄⠹⣷⣟⣿⣄⠹⣟⣿⣿⣟⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⢸⣯⣟⣧⠘⣷⠈⡯⠛⢀⡐⢾⣟⣷⣻⣿⣿⣿⡿⡌⢿⣻⣿⣿
⣿⣿⣿⣿⣿⣿⣧⢸⡿⣟⣿⡇⢸⣯⣟⣮⢧⡈⢿⣞⡿⣦⠘⠏⣹⣿⣽⢿⣿⣿⣿⣿⣯⣿⣿⣿⡇⢸⣿⣿⣾⡆⠹⢀⣠⣾⣟⣷⡈⢿⣞⣯⢿⣿⣿⣿⢷⠘⣯⣿⣿
⣿⣿⣿⣿⣿⣿⣿⡈⣿⢿⣽⡇⠘⠛⠛⠛⠓⠓⠈⠛⠛⠟⠇⢀⢿⣻⣿⣯⢿⣿⣿⣿⣷⢿⣿⣿⠁⣾⣿⣿⣿⣧⡄⠇⣹⣿⣾⣯⣿⡄⠻⣽⣯⢿⣻⣿⣿⡇⢹⣾⣿
⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⡽⡇⢸⣿⣿⣿⣿⣿⣞⣆⠰⣶⣶⡄⢀⢻⡿⣯⣿⡽⣿⣿⣿⢯⣟⡿⢀⣿⣿⣿⣿⣿⣧⠐⣸⣿⣿⣷⣿⣿⣆⠹⣯⣿⣻⣿⣿⣿⢀⣿⢿
⣿⣿⣿⣿⣿⣿⣿⣿⠘⣯⡿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣧⡈⢿⣳⠘⡄⠻⣿⢾⣽⣟⡿⣿⢯⣿⡇⢸⣿⣿⣿⣿⣿⣿⡀⢾⣿⣿⣿⣿⣿⣿⣆⠹⣾⣷⣻⣿⡿⡇⢸⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠻⡇⢹⣆⠹⣟⣾⣽⣻⣟⣿⣽⠁⣾⣿⣿⣿⣿⣿⣿⣇⣿⣿⠿⠛⠛⠉⠙⠋⢀⠁⢘⣯⣿⣿⣧⠘⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⡈⣿⡃⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡙⠌⣿⣆⠘⣿⣞⡿⣞⡿⡞⢠⣿⣿⣿⣿⣿⡿⠛⠉⠁⢀⣀⣠⣤⣤⣶⣶⣶⡆⢻⣽⣞⡿⣷⠈⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠘⠁⠉⠉⠉⠉⠉⠉⠉⠉⠉⠙⠛⠛⢿⣄⢻⣿⣧⠘⢯⣟⡿⣽⠁⣾⣿⣿⣿⣿⣿⡃⢀⢀⠘⠛⠿⢿⣻⣟⣯⣽⣻⣵⡀⢿⣯⣟⣿⢀⣿
⣿⣿⣿⣟⣿⣿⣿⣿⣶⣶⡆⢀⣿⣾⣿⣾⣷⣿⣶⠿⠚⠉⢀⢀⣤⣿⣷⣿⣿⣷⡈⢿⣻⢃⣼⣿⣿⣿⣿⣻⣿⣿⣿⡶⣦⣤⣄⣀⡀⠉⠛⠛⠷⣯⣳⠈⣾⡽⣾⢀⣿
⣿⢿⣿⣿⣻⣿⣿⣿⣿⣿⡿⠐⣿⣿⣿⣿⠿⠋⠁⢀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣌⣥⣾⡿⣿⣿⣷⣿⣿⢿⣷⣿⣿⣟⣾⣽⣳⢯⣟⣶⣦⣤⡾⣟⣦⠘⣿⢾⡁⢺
⣿⣻⣿⣿⡷⣿⣿⣿⣿⣿⡗⣦⠸⡿⠋⠁⢀⢀⣠⣴⢿⣿⣽⣻⢽⣾⣟⣷⣿⣟⣿⣿⣿⣳⠿⣵⣧⣼⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣽⣳⣯⣿⣿⣿⣽⢀⢷⣻⠄⠘
⣿⢷⣻⣿⣿⣷⣻⣿⣿⣿⡷⠛⣁⢀⣀⣤⣶⣿⣛⡿⣿⣮⣽⡻⣿⣮⣽⣻⢯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢀⢸⣿⢀⡆
⠸⣟⣯⣿⣿⣷⢿⣽⣿⣿⣷⣿⣷⣆⠹⣿⣶⣯⠿⣿⣶⣟⣻⢿⣷⣽⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣯⣟⢀⡇
⣇⠹⣟⣾⣻⣿⣿⢾⡽⣿⣿⣿⣿⣿⣆⢹⣶⣿⣻⣷⣯⣟⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢀⡿⡇⢸⡇
⣿⣆⠹⣷⡻⣽⣿⣯⢿⣽⣻⣿⣿⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⠇⣼⡇
⡙⠾⣆⠹⣿⣦⠛⣿⢯⣷⢿⡽⣿⣿⣿⣿⣆⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠎⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣿⣾⣣⡿⡇
⣿⣷⡌⢦⠙⣿⣿⣌⠻⣽⢯⣿⣽⣻⣿⣿⣿⣧⠩⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⢰⢣⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⢀⢀⢿⣞⣷⢿⡇
⣿⣽⣆⠹⣧⠘⣿⣿⡷⣌⠙⢷⣯⡷⣟⣿⣿⣿⣷⡀⡹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣈⠃⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢀⣴⡧⢀⠸⣿⡽⣿⢀
⢻⣽⣿⡄⢻⣷⡈⢿⣿⣿⢧⢀⠙⢿⣻⡾⣽⣻⣿⣿⣄⠌⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢁⣰⣾⣟⡿⢀⡄⢿⣟⣿⢀
⡄⢿⣿⣷⢀⠹⣟⣆⠻⣿⣿⣆⢀⣀⠉⠻⣿⡽⣯⣿⣿⣷⣈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢀⣠⠘⣯⣷⣿⡟⢀⢆⠸⣿⡟⢸
⣷⡈⢿⣿⣇⢱⡘⢿⣷⣬⣙⠿⣧⠘⣆⢀⠈⠻⣷⣟⣾⢿⣿⣆⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⡞⢡⣿⢀⣿⣿⣿⠇⡄⢸⡄⢻⡇⣼
⣿⣷⡈⢿⣿⡆⢣⡀⠙⢾⣟⣿⣿⣷⡈⠂⠘⣦⡈⠿⣯⣿⢾⣿⣆⠙⠻⠿⠿⠿⠿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢋⣠⣾⡟⢠⣿⣿⢀⣿⣿⡟⢠⣿⢈⣧⠘⢠⣿
⣿⣿⣿⣄⠻⣿⡄⢳⡄⢆⡙⠾⣽⣿⣿⣆⡀⢹⡷⣄⠙⢿⣿⡾⣿⣆⢀⡀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣀⣠⣴⡿⣯⠏⣠⣿⣿⡏⢸⣿⡿⢁⣿⣿⢀⣿⠆⢸⣿
⣿⣿⣿⣿⣦⡙⣿⣆⢻⡌⢿⣶⢤⣉⣙⣿⣷⡀⠙⠽⠷⠄⠹⣿⣟⣿⣆⢙⣋⣤⣤⣤⣄⣀⢀⢀⢀⢀⣾⣿⣟⡷⣯⡿⢃⣼⣿⣿⣿⠇⣼⡟⣡⣿⣿⣿⢀⡿⢠⠈⣿
⣿⣿⣿⣿⣿⣷⣮⣿⣿⣿⡌⠁⢤⣤⣤⣤⣬⣭⣴⣶⣶⣶⣆⠈⢻⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣷⣶⣤⣌⣉⡘⠛⠻⠶⣿⣿⣿⣿⡟⣰⣫⣴⣿⣿⣿⣿⠄⣷⣿⣿⣿
*/

#include <bits/stdc++.h>

using namespace std;

//#define MULTITEST

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 10 * 1000 + 13;
const int LOGN = 30;

int n;
int a[N], b[N];

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n)
		scanf("%d", &a[i]);
	forn(i, n)
		scanf("%d", &b[i]);
	return true;
}

pt bas1[LOGN], bas2[LOGN];
bool used[LOGN];

bool add(int a[N], int x, int pos, pt bas[LOGN], vector<pt> &moves){
	for (int i = LOGN - 1; i >= 0; --i) if ((x >> i) & 1){
		if (bas[i].x == -1){
			bas[i] = mp(x, pos);
			return true;
		}
		moves.pb(mp(pos, bas[i].y));
		a[pos] ^= a[bas[i].y];
		x ^= bas[i].x;
	}
	return false;
}

vector<int> addpos(int x, pt bas[LOGN]){
	vector<int> res;
	for (int i = LOGN - 1; i >= 0; --i) if ((x >> i) & 1){
		if (bas[i].x == -1)
			return {};
		res.pb(i);
		x ^= bas[i].x;
	}
	return res;
}

void getbas(int a[N], pt bas[LOGN], vector<pt> &moves){
	forn(i, LOGN) bas[i] = mp(-1, -1);
	forn(i, n) add(a, a[i], i, bas, moves);
}

int mt[LOGN];

void solve() {
	vector<pt> p1, p2;
	getbas(a, bas1, p1);
	getbas(b, bas2, p2);
	reverse(all(p2));

	//cerr << vector<int>(a, a + n) << endl;
	//cerr << vector<int>(b, b + n) << endl;

	vector<pt> p3;
	memset(used, 0, sizeof(used));
	forn(i, LOGN) if (bas2[i].x != -1){
		auto tmp = addpos(bas2[i].x, bas1);
		if (tmp.empty()){
			puts("-1");
			return;
		}
		bool made = false;
		for (int j : tmp) if (!used[j]){
			made = true;
			used[j] = true;
			for (int k : tmp) if (k != j)
				p3.pb(mp(bas1[j].y, bas1[k].y));
			a[bas1[j].y] = b[bas2[i].y];
			bas1[j].x = bas2[i].x;
			mt[j] = i;
			break;
		}
		assert(made);
	}

	//cerr << vector<int>(a, a + n) << endl;
	//cerr << vector<int>(b, b + n) << endl;

	forn(i, LOGN) if (used[i]){
		int j = mt[i];
		if (bas1[i].y != bas2[j].y){
			p3.pb(mp(bas1[i].y, bas2[j].y));
			p3.pb(mp(bas2[j].y, bas1[i].y));
			p3.pb(mp(bas1[i].y, bas2[j].y));
			swap(a[bas1[i].y], a[bas2[j].y]);
			forn(k, LOGN) if (bas1[k].y == bas2[j].y)
				bas1[k].y = bas1[i].y;
			bas1[i].y = bas2[j].y;
		}
	}

	forn(i, n) if (a[i] != b[i]){
		p3.pb(mp(i, i));
		a[i] = 0;
		int x = b[i];
		for (int j = LOGN - 1; j >= 0; --j) if ((x >> j) & 1){
			p3.pb(mp(i, bas1[j].y));
			a[i] ^= a[bas1[j].y];
			x ^= bas1[j].x;
		}
	}

	//cerr << p1 << endl << p2 << endl << p3 << endl;

	vector<pt> tot;
	for (auto it : p1) tot.pb(it);
	for (auto it : p3) tot.pb(it);
	for (auto it : p2) tot.pb(it);

	printf("%d\n", sz(tot));
	for (auto it : tot)
		printf("%d %d\n", it.x + 1, it.y + 1);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int tt = clock();

#endif

	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef MULTITEST
	int tc;
	scanf("%d", &tc);
	while(tc--){
		read();
#else
	while(read()) {
#endif
		solve();

#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}


#include<bits/stdc++.h>
using namespace std;

const int N = 1e4 + 5;

int n, a[N], b[N];
vector < pair < int, int > > ans1, ans2;

int main(){
    ios_base::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];
    }
    for(int i = 1, j = 30; i <= n && j >= 0; j--){
        for(int k = i; k <= n; k++){
            if(a[k] & (1 << j)){
                if(i == k){
                    break;
                }
                a[i] ^= a[k];
                ans1.push_back(make_pair(i, k));
                break;
            }
        }
        if((a[i] & (1 << j)) == 0){
            continue;
        }
        for(int k = 1; k <= n; k++){
            if(k != i && (a[k] & (1 << j))){
                a[k] ^= a[i];
                ans1.push_back(make_pair(k, i));
            }
        }
        i++;
    }
    for(int i = 1, j = 30; i <= n && j >= 0; j--){
        for(int k = i; k <= n; k++){
            if(b[k] & (1 << j)){
                if(i == k){
                    break;
                }
                b[i] ^= b[k];
                ans2.push_back(make_pair(i, k));
                break;
            }
        }
        if((b[i] & (1 << j)) == 0){
            continue;
        }
        for(int k = 1; k <= n; k++){
            if(k != i && (b[k] & (1 << j))){
                b[k] ^= b[i];
                ans2.push_back(make_pair(k, i));
            }
        }
        i++;
    }
    for(int i = 1; i <= n; i++){
        int x = a[i], y = b[i];
        for(int j = 30; j >= 0; j--){
            if(((x ^ y) >> j) & 1){
                for(int k = 1; k <= n; k++){
                    if((a[k] >> j) & 1){
                        ans1.push_back(make_pair(i, k));
                        x ^= a[k];
                        break;
                    }
                }
            }
        }
        if(x != y){
            return cout << "-1", 0;
        }
    }
    cout << ans1.size() + ans2.size() << "\n";
    for(auto it : ans1){
        cout << it.first << " " << it.second << "\n";
    }
    reverse(ans2.begin(), ans2.end());
    for(auto it : ans2){
        cout << it.first << " " << it.second << "\n";
    }
}


#include<bits/stdc++.h>
using namespace std;

const int N = 1e4 + 5;

int n, a[N], b[N];
vector < pair < int, int > > ans1, ans2;

int main(){
    ios_base::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];
    }
    for(int i = 1, j = 30; i <= n && j >= 0; j--){
        for(int k = i; k <= n; k++){
            if(a[k] & (1 << j)){
                if(i == k){
                    break;
                }
                a[i] ^= a[k];
                ans1.push_back(make_pair(i, k));
                break;
            }
        }
        if((a[i] & (1 << j)) == 0){
            continue;
        }
        for(int k = 1; k <= n; k++){
            if(k != i && (a[k] & (1 << j))){
                a[k] ^= a[i];
                ans1.push_back(make_pair(k, i));
            }
        }
        i++;
    }
    for(int i = 1, j = 30; i <= n && j >= 0; j--){
        for(int k = i; k <= n; k++){
            if(b[k] & (1 << j)){
                if(i == k){
                    break;
                }
                b[i] ^= b[k];
                ans2.push_back(make_pair(i, k));
                break;
            }
        }
        if((b[i] & (1 << j)) == 0){
            continue;
        }
        for(int k = 1; k <= n; k++){
            if(k != i && (b[k] & (1 << j))){
                b[k] ^= b[i];
                ans2.push_back(make_pair(k, i));
            }
        }
        i++;
    }
    for(int i = 1; i <= n; i++){
        int x = a[i], y = b[i];
        for(int j = 30; j >= 0; j--){
            if(((x ^ y) >> j) & 1){
                for(int k = i; k <= n; k++){
                    if((a[k] >> j) & 1){
                        ans1.push_back(make_pair(i, k));
                        x ^= a[k];
                        break;
                    }
                }
            }
        }
        if(x != y){
            return cout << "-1", 0;
        }
    }
    cout << ans1.size() + ans2.size() << "\n";
    for(auto it : ans1){
        cout << it.first << " " << it.second << "\n";
    }
    reverse(ans2.begin(), ans2.end());
    for(auto it : ans2){
        cout << it.first << " " << it.second << "\n";
    }
}


#include<bits/stdc++.h>
using namespace std;

const int N = 1e4 + 5;

int n, a[N], b[N];
vector < pair < int, int > > ans1, ans2;

int main(){
    ios_base::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];
    }
    for(int i = 1, j = 30; i <= n && j >= 0; j--){
        for(int k = i; k <= n; k++){
            if(a[k] & (1 << j)){
                if(i == k){
                    break;
                }
                a[i] ^= a[k];
                ans1.push_back(make_pair(i, k));
                break;
            }
        }
        if((a[i] & (1 << j)) == 0){
            continue;
        }
        for(int k = 1; k <= n; k++){
            if(k != i && (a[k] & (1 << j))){
                a[k] ^= a[i];
                ans1.push_back(make_pair(k, i));
            }
        }
        i++;
    }
    for(int i = 1, j = 30; i <= n && j >= 0; j--){
        for(int k = i; k <= n; k++){
            if(b[k] & (1 << j)){
                if(i == k){
                    break;
                }
                b[i] ^= b[k];
                ans2.push_back(make_pair(i, k));
                break;
            }
        }
        if((b[i] & (1 << j)) == 0){
            continue;
        }
        for(int k = 1; k <= n; k++){
            if(k != i && (b[k] & (1 << j))){
                b[k] ^= b[i];
                ans2.push_back(make_pair(k, i));
            }
        }
        i++;
    }
    for(int i = 1; i <= n; i++){
        cout << a[i] << " ";
    }
    cout << "\n";
    for(int i = 1; i <= n; i++){
        cout << b[i] << " ";
    }
    return 0;
    for(int i = 1; i <= n; i++){
        int x = a[i], y = b[i];
        for(int j = 30; j >= 0; j--){
            if(((x ^ y) >> j) & 1){
                for(int k = 1; k <= i; k++){
                    if((a[k] >> j) & 1){
                        ans1.push_back(make_pair(i, k));
                        x ^= a[k];
                        break;
                    }
                }
            }
        }
        if(x != y){
            return cout << "-1", 0;
        }
    }
    cout << ans1.size() + ans2.size() << "\n";
    for(auto it : ans1){
        cout << it.first << " " << it.second << "\n";
    }
    reverse(ans2.begin(), ans2.end());
    for(auto it : ans2){
        cout << it.first << " " << it.second << "\n";
    }
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

const ll MAXN=1e4+10;
const ll MAX_LOG=32;

vector <pll> res[2];

ll a[2][MAXN];
ll w[2][MAXN];

ll z[2][MAX_LOG];

ll n;

void normalize(ll id)
{
    fill(w[id] , w[id]+MAXN , -1);

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                w[id][j]=i;
                z[id][i]=j;
                break;
            }
        }

        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                res[id].pb(mp(j , z[id][i]));
                a[id][j]^=a[id][z[id][i]];
            }
        }
    }

    ll p=1;

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (z[id][i]>0)
        {
            if (z[id][i]>p)
            {
                res[id].pb(mp(p , z[id][i]));
                res[id].pb(mp(z[id][i] , p));
                res[id].pb(mp(p , z[id][i]));

                if (w[id][p]==-1)
                {
                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    z[id][i]=p;
                }
                else
                {
                    ll d=w[id][p];

                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    swap(z[id][i] , z[id][d]);
                }
            }

            p++;
        }
    }
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);

	cin>>n;

	for(ll i=0;i<2;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            cin>>a[i][j];
        }

        normalize(i);
    }

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (z[1][i]>0)
        {
            if (z[0][i]==0)
            {
                cout<<-1;
                return 0;
            }

            for(ll j=z[0][i]+1;j<=n && a[0][j]>0;j++)
            {
                if (BIT(a[0][z[0][i]] , w[0][j])!=BIT(a[1][z[1][i]] , w[0][j]))
                {
                    res[0].pb(mp(z[0][i] , j));
                    a[0][z[0][i]]^=a[0][j];
                }
            }

            if (a[0][z[0][i]]!=a[1][z[1][i]])
            {
                cout<<-1;
                return 0;
            }
        }
        else
        {
            if (z[0][i]>0)
            {
                res[0].pb(mp(z[0][i] , z[0][i]));
                a[0][z[0][i]]=0;
            }
        }
    }

    ll p=1;

    for(ll i=1;i<=n;i++)
    {
        if (a[0][i]>0 && p!=i)
        {
            res[0].pb(mp(i , p));
            res[0].pb(mp(p , i));
            res[0].pb(mp(i , p));

            swap(a[0][i] , a[0][p]);
            p++;
        }
    }

    cout<<(ll)(res[0].size())+(ll)(res[1].size())<<endl;

    for(ll i=0;i<res[0].size();i++)
    {
        cout<<res[0][i].X<<" "<<res[0][i].Y<<endl;
    }

    for(ll i=0;i<res[1].size();i++)
    {
        cout<<res[1][i].Y<<" "<<res[1][i].X<<endl;
    }
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

const ll MAXN=1e4+10;
const ll MAX_LOG=32;

vector <pll> res[2];

ll a[2][MAXN];
ll w[2][MAXN];

ll z[2][MAX_LOG];

ll n;

void normalize(ll id)
{
    fill(w[id] , w[id]+MAXN , -1);

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                w[id][j]=i;
                z[id][i]=j;
                break;
            }
        }

        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                res[id].pb(mp(j , z[id][i]));
                a[id][j]^=a[id][z[id][i]];
            }
        }
    }

    ll p=1;

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (z[id][i]>0)
        {
            if (z[id][i]>p)
            {
                res[id].pb(mp(p , z[id][i]));
                res[id].pb(mp(z[id][i] , p));
                res[id].pb(mp(p , z[id][i]));

                if (w[id][p]==-1)
                {
                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    z[id][i]=p;
                }
                else
                {
                    ll d=w[id][p];

                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    swap(z[id][i] , z[id][d]);
                }
            }

            p++;
        }
    }
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);

	cin>>n;

	for(ll i=0;i<2;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            cin>>a[i][j];
        }

        normalize(i);
    }

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (z[1][i]>0)
        {
            if (z[0][i]==0)
            {
                cout<<-1;
                return 0;
            }

            for(ll j=z[0][i]+1;j<=n && a[0][j]>0;j++)
            {
                if (BIT(a[0][z[0][i]] , w[0][j])!=BIT(a[1][z[1][i]] , w[0][j]))
                {
                    res[0].pb(mp(z[0][i] , j));
                    a[0][z[0][i]]^=a[0][j];
                }
            }

            if (a[0][z[0][i]]!=a[1][z[1][i]])
            {
                cout<<-1;
                return 0;
            }
        }
        else
        {
            if (z[0][i]>0)
            {
                res[0].pb(mp(z[0][i] , z[0][i]));
                a[0][z[0][i]]=0;
            }
        }
    }

    ll p=1;

    for(ll i=1;i<=n;i++)
    {
        if (a[0][i]>0)
        {
            if (i!=p)
            {
                res[0].pb(mp(i , p));
                res[0].pb(mp(p , i));
                res[0].pb(mp(i , p));

                swap(a[0][i] , a[0][p]);
            }

            p++;
        }
    }

    cout<<(ll)(res[0].size())+(ll)(res[1].size())<<endl;

    for(ll i=0;i<res[0].size();i++)
    {
        cout<<res[0][i].X<<" "<<res[0][i].Y<<endl;
    }

    for(ll i=(ll)(res[1].size())-1;i>=0;i--)
    {
        cout<<res[1][i].X<<" "<<res[1][i].Y<<endl;
    }
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

const ll MAXN=1e4+10;
const ll MAX_LOG=32;

vector <pll> res[2];

ll a[2][MAXN];
ll w[2][MAXN];

ll z[2][MAX_LOG];

ll n;

void normalize(ll id)
{
    fill(w[id] , w[id]+MAXN , -1);

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                w[id][j]=i;
                z[id][i]=j;
                break;
            }
        }

        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                res[id].pb(mp(j , z[id][i]));
                a[id][j]^=a[id][z[id][i]];
            }
        }
    }

    ll p=1;

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (z[id][i]>0)
        {
            if (z[id][i]>p)
            {
                res[id].pb(mp(p , z[id][i]));
                res[id].pb(mp(z[id][i] , p));
                res[id].pb(mp(p , z[id][i]));

                if (w[id][p]==-1)
                {
                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    z[id][i]=p;
                }
                else
                {
                    ll d=w[id][p];

                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    swap(z[id][i] , z[id][d]);
                }
            }

            p++;
        }
    }
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);

	cin>>n;

	for(ll i=0;i<2;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            cin>>a[i][j];
        }

        normalize(i);
    }

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (z[1][i]>0)
        {
            if (z[0][i]==0)
            {
                cout<<-1;
                return 0;
            }

            for(ll j=z[0][i]+1;j<=n && a[0][j]>0;j++)
            {
                if (BIT(a[0][z[0][i]] , w[0][j])!=BIT(a[1][z[1][i]] , w[0][j]))
                {
                    res[0].pb(mp(z[0][i] , j));
                    a[0][z[0][i]]^=a[0][j];
                }
            }

            if (a[0][z[0][i]]!=a[1][z[1][i]])
            {
                cout<<-1;
                return 0;
            }
        }
        else
        {
            if (z[0][i]>0)
            {
                res[0].pb(mp(z[0][i] , z[0][i]));
                a[0][z[0][i]]=0;
            }
        }
    }

    ll p=1;

    for(ll i=1;i<=n;i++)
    {
        if (a[0][i]>0 && p!=i)
        {
            res[0].pb(mp(i , p));
            res[0].pb(mp(p , i));
            res[0].pb(mp(i , p));

            swap(a[0][i] , a[0][p]);
        }
    }

    cout<<(ll)(res[0].size())+(ll)(res[1].size())<<endl;

    for(ll i=0;i<res[0].size();i++)
    {
        cout<<res[0][i].X<<" "<<res[0][i].Y<<endl;
    }

    for(ll i=0;i<res[1].size();i++)
    {
        cout<<res[1][i].Y<<" "<<res[1][i].X<<endl;
    }
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

const ll MAXN=1e4+10;
const ll MAX_LOG=32;

vector <pll> res[2];

ll a[2][MAXN];
ll w[2][MAXN];

ll z[2][MAX_LOG];

ll n;

void normalize(ll id)
{
    fill(w[id] , w[id]+MAXN , -1);

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                w[id][j]=i;
                z[id][i]=j;
                break;
            }
        }

        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                res[id].pb(mp(j , z[id][i]));
                a[id][j]^=a[id][z[id][i]];
            }
        }
    }

    ll p=1;

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (a[id][z[id][i]]>0)
        {
            if (z[id][i]>p)
            {
                res[id].pb(mp(p , z[id][i]));
                res[id].pb(mp(z[id][i] , p));
                res[id].pb(mp(p , z[id][i]));

                if (w[id][p]==-1)
                {
                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    z[id][i]=p;
                }
                else
                {
                    ll d=w[id][p];

                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    swap(z[id][i] , z[id][d]);
                }
            }

            p++;
        }
    }
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);

	cin>>n;

	for(ll i=0;i<2;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            cin>>a[i][j];
        }

        normalize(i);
    }

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (z[1][i]>0)
        {
            if (z[0][i]==0)
            {
                cout<<-1;
                return 0;
            }

            for(ll j=z[0][i]+1;j<=n && a[0][j]>0;j++)
            {
                if (BIT(a[0][z[0][i]] , w[0][j])!=BIT(a[1][z[1][i]] , w[0][j]))
                {
                    res[0].pb(mp(z[0][i] , j));
                    a[0][z[0][i]]^=a[0][j];
                }
            }

            if (a[0][z[0][i]]!=a[1][z[1][i]])
            {
                cout<<-1;
                return 0;
            }
        }
        else
        {
            if (z[0][i]>0)
            {
                res[0].pb(mp(z[0][i] , z[0][i]));
                a[0][z[0][i]]=0;
            }
        }
    }

    ll p=1;

    for(ll i=1;i<=n;i++)
    {
        if (a[0][i]>0 && p!=i)
        {
            res[0].pb(mp(i , p));
            res[0].pb(mp(p , i));
            res[0].pb(mp(i , p));

            swap(a[0][i] , a[0][p]);
            p++;
        }
    }

    cout<<(ll)(res[0].size())+(ll)(res[1].size())<<endl;

    for(ll i=0;i<res[0].size();i++)
    {
        cout<<res[0][i].X<<" "<<res[0][i].Y<<endl;
    }

    for(ll i=(ll)(res[1].size())-1;i>=0;i--)
    {
        cout<<res[1][i].X<<" "<<res[1][i].Y<<endl;
    }
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

const ll MAXN=1e4+10;
const ll MAX_LOG=32;

vector <pll> res[2];

ll a[2][MAXN];
ll w[2][MAXN];

ll z[2][MAX_LOG];

ll n;

void normalize(ll id)
{
    fill(w[id] , w[id]+MAXN , -1);

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                w[id][j]=i;
                z[id][i]=j;
                break;
            }
        }

        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                res[id].pb(mp(j , z[id][i]));
                a[id][j]^=a[id][z[id][i]];
            }
        }
    }

    ll p=1;

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (z[id][i]>0)
        {
            if (z[id][i]>p)
            {
                res[id].pb(mp(p , z[id][i]));
                res[id].pb(mp(z[id][i] , p));

                if (w[id][p]==-1)
                {
                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    z[id][i]=p;
                }
                else
                {
                    ll d=w[id][p];

                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    swap(z[id][i] , z[id][d]);
                }
            }

            p++;
        }
    }
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);

	cin>>n;

	for(ll i=0;i<2;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            cin>>a[i][j];
        }

        normalize(i);
    }

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (z[1][i]>0)
        {
            if (z[0][i]==0)
            {
                cout<<-1;
                return 0;
            }

            for(ll j=z[0][i]+1;j<=n && a[0][j]>0;j++)
            {
                if (BIT(a[0][z[0][i]] , w[0][j])!=BIT(a[1][z[1][i]] , w[0][j]))
                {
                    res[0].pb(mp(z[0][i] , j));
                    a[0][z[0][i]]^=a[0][j];
                }
            }

            if (a[0][z[0][i]]!=a[1][z[1][i]])
            {
                cout<<-1;
                return 0;
            }
        }
        else
        {
            if (z[0][i]>0)
            {
                res[0].pb(mp(z[0][i] , z[0][i]));
                a[0][z[0][i]]=0;
            }
        }
    }

    ll p=1;

    for(ll i=1;i<=n;i++)
    {
        if (a[0][i]>0 && p!=i)
        {
            res[0].pb(mp(i , p));
            res[0].pb(mp(p , i));

            swap(a[0][i] , a[0][p]);
        }
    }

    cout<<(ll)(res[0].size())+(ll)(res[1].size())<<endl;

    for(ll i=0;i<res[0].size();i++)
    {
        cout<<res[0][i].X<<" "<<res[0][i].Y<<endl;
    }

    for(ll i=0;i<res[1].size();i++)
    {
        cout<<res[1][i].Y<<" "<<res[1][i].X<<endl;
    }
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

const ll MAXN=1e4+10;
const ll MAX_LOG=32;

vector <pll> res[2];

ll a[2][MAXN];
ll w[2][MAXN];

ll z[2][MAX_LOG];

ll n;

void normalize(ll id)
{
    fill(w[id] , w[id]+MAXN , -1);

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                w[id][j]=i;
                z[id][i]=j;
                break;
            }
        }

        for(ll j=1;j<=n;j++)
        {
            if (w[id][j]==-1 && BIT(a[id][j] , i))
            {
                res[id].pb(mp(j , z[id][i]));
                a[id][j]^=a[id][z[id][i]];
            }
        }
    }

    ll p=1;

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (z[id][i]>0)
        {
            if (z[id][i]>p)
            {
                res[id].pb(mp(p , z[id][i]));
                res[id].pb(mp(z[id][i] , p));
                res[id].pb(mp(p , z[id][i]));

                if (w[id][p]==-1)
                {
                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    z[id][i]=p;
                }
                else
                {
                    ll d=w[id][p];

                    swap(w[id][p] , w[id][z[id][i]]);
                    swap(a[id][p] , a[id][z[id][i]]);
                    swap(z[id][i] , z[id][d]);
                }
            }

            p++;
        }
    }
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);

	cin>>n;

	for(ll i=0;i<2;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            cin>>a[i][j];
        }

        normalize(i);
    }

    for(ll i=MAX_LOG-1;i>=0;i--)
    {
        if (z[1][i]>0)
        {
            if (z[0][i]==0)
            {
                cout<<-1;
                return 0;
            }

            for(ll j=z[0][i]+1;j<=n && a[0][j]>0;j++)
            {
                if (BIT(a[0][z[0][i]] , w[0][j])!=BIT(a[1][z[1][i]] , w[0][j]))
                {
                    res[0].pb(mp(z[0][i] , j));
                    a[0][z[0][i]]^=a[0][j];
                }
            }

            if (a[0][z[0][i]]!=a[1][z[1][i]])
            {
                cout<<-1;
                return 0;
            }
        }
        else
        {
            if (z[0][i]>0)
            {
                res[0].pb(mp(z[0][i] , z[0][i]));
                a[0][z[0][i]]=0;
            }
        }
    }

    ll p=1;

    for(ll i=1;i<=n;i++)
    {
        if (a[0][i]>0 && p!=i)
        {
            res[0].pb(mp(i , p));
            res[0].pb(mp(p , i));
            res[0].pb(mp(i , p));

            swap(a[0][i] , a[0][p]);
            p++;
        }
    }

    cout<<(ll)(res[0].size())+(ll)(res[1].size())<<endl;

    for(ll i=0;i<res[0].size();i++)
    {
        cout<<res[0][i].X<<" "<<res[0][i].Y<<endl;
    }

    for(ll i=(ll)(res[1].size())-1;i>=0;i--)
    {
        cout<<res[1][i].X<<" "<<res[1][i].Y<<endl;
    }
}


// modifying https://codeforces.com/contest/472/submission/8020297, to understand it
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int N;
int x[12345], y[12345];

vector<pair<int, int> > ans;
vector<pair<int, int> > ans2;

void as(int i, int j, vector<pair<int, int> >& ans)
{
	ans.push_back(make_pair(i + 1, j + 1));
}

void f(int x[], vector<pair<int, int> >& ans)
{
	for(int j = 1 << 30, k = 0; j && k < N; j >>= 1)
	{
		for(int i = k; i < N; i++)
			if(x[i] & j)
			{
				if(i != k)
				{
					swap(x[i], x[k]);
					as(i, k, ans);
					as(k, i, ans);
					as(i, k, ans);
				}
				break;
			}
		if(x[k] & j)
		{
			for(int i = 0; i < N; i++)
				if(i != k && (x[i] & j))
				{
					x[i] ^= x[k];
					as(i, k, ans);
				}
			k++;
		}
	}
}
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);
	f(x, ans);
	f(y, ans2);
	bool ok = true; int ref = -1;
	for(int i = 0; ok && i < N; i++)
		if(y[i])
		{
			int idx = -1;
			for(int j = ref+1; j < N; j++)
				if(((y[i] & x[j]) << 1) > y[i] && ((y[i] & x[j]) << 1) > x[j])
					idx = j;
			ref = idx;
			for(int j = idx+1; j < N; j++)
				if(((y[i] & x[j]) << 1) > x[j])
				{
					x[idx] ^= x[j];
					as(idx, j, ans);
				}

			if(idx == -1 || x[idx] != y[i])
				ok = false;
			else if(idx != i)
			{
				swap(x[i], x[idx]);
				as(i, idx, ans);
				as(idx, i, ans);
				as(i, idx, ans);
			}
		}
	if(!ok)
		puts("-1");
	else
	{
		for(int i = 0; i < N; i++)
			if(x[i] != y[i])
				as(i, i, ans);
		printf("%d\n", (int)(ans.size() + ans2.size()));
		for(int i = 0; i < ans.size(); i++)
			printf("%d %d\n", ans[i].first, ans[i].second);
		for(int i = ans2.size() - 1; i >= 0; i--)
			printf("%d %d\n", ans2[i].first, ans2[i].second);
	}
	return 0;
}


// modifying https://codeforces.com/contest/472/submission/8020297, to understand it
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int N;
int x[12345], y[12345];

vector<pair<int, int> > ans;
vector<pair<int, int> > ans2;

void as(int i, int j, vector<pair<int, int> >& ans)
{
    ans.push_back(make_pair(i + 1, j + 1));
}

void f(int x[], vector<pair<int, int> >& ans)
{
    for(int j = 1 << 30, k = 0; j && k < N; j >>= 1)
    {
        for(int i = k; i < N; i++)
            if(x[i] & j)
            {
                if(i != k)
                {
                    swap(x[i], x[k]);
                    as(i, k, ans);
                    as(k, i, ans);
                    as(i, k, ans);
                }
                break;
            }

        if(x[k] & j)
        {
            for(int i = 0; i < N; i++)
                if(i != k && (x[i] & j))
                {
                    x[i] ^= x[k];
                    as(i, k, ans);
                }
            k++;
        }
    }
}

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);

    f(x, ans);
    f(y, ans2);

    bool ok = true;
    for(int i = 0; ok && i < N; i++)
        if(y[i])
        {
            int idx = -1;
            for(int j = 0; j < N; j++)
                if(((y[i] & x[j]) << 1) > y[i] && ((y[i] & x[j]) << 1) > x[j])
                    idx = j;

            for(int j = idx+1; j < N; j++)
                if(((y[i] & x[j]) << 1) > x[j])
                {
                    x[idx] ^= x[j];
                    as(idx, j, ans);
                }

            if(idx == -1 || x[idx] != y[i])
                ok = false;
            else if(idx != i)
            {
                swap(x[i], x[idx]);
                as(i, idx, ans);
                as(idx, i, ans);
                as(i, idx, ans);
            }
        }

    if(!ok)
        puts("-1");
    else
    {
        for(int i = 0; i < N; i++)
            if(x[i] != y[i])
                as(i, i, ans);

        printf("%d\n", (int)(ans.size() + ans2.size()));
        for(int i = 0; i < ans.size(); i++)
            printf("%d %d\n", ans[i].first, ans[i].second);
        for(int i = ans2.size() - 1; i >= 0; i--)
            printf("%d %d\n", ans2[i].first, ans2[i].second);
    }

    return 0;
}


// modifying https://codeforces.com/contest/472/submission/8020297, to understand it
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int N;
int x[12345], y[12345];
vector<pair<int, int> > ans;
vector<pair<int, int> > ans2;
void as(int i, int j, vector<pair<int, int> >& ans)
{
	ans.push_back(make_pair(i + 1, j + 1));
}
void f(int x[], vector<pair<int, int> >& ans)
{
	for(int j = 1 << 30, k = 0; j && k < N; j >>= 1)
	{
		for(int i = k; i < N; i++)
			if(x[i] & j)
			{
				if(i != k)
				{
					swap(x[i], x[k]);
					as(i, k, ans);
					as(k, i, ans);
					as(i, k, ans);
				}
				break;
			}
		if(x[k] & j)
		{
			for(int i = 0; i < N; i++)
				if(i != k && (x[i] & j))
				{
					x[i] ^= x[k];
					as(i, k, ans);
				}
			k++;
		}
	}
}
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);
	f(x, ans);
	f(y, ans2);
	bool ok = true;
	for(int i = 0; ok && i < N; i++)
		if(y[i])
		{
			int idx = -1;
			for(int j = 0; j < N; j++)
				if(((y[i] & x[j]) << 1) > y[i] && ((y[i] & x[j]) << 1) > x[j])
					idx = j;
			for(int j = idx+1; j < N; j++)
				if(((y[i] & x[j]) << 1) > x[j])
				{
					x[idx] ^= x[j];
					as(idx, j, ans);
				}
			if(idx == -1 || x[idx] != y[i])
				ok = false;
			else if(idx != i)
			{
				swap(x[i], x[idx]);
				as(i, idx, ans);
				as(idx, i, ans);
				as(i, idx, ans);
			}
		}
	if(!ok)
		puts("-1");
	else
	{
		for(int i = 0; i < N; i++)
			if(x[i] != y[i])
				as(i, i, ans);
		printf("%d\n", (int)(ans.size() + ans2.size()));
		for(int i = 0; i < ans.size(); i++)
			printf("%d %d\n", ans[i].first, ans[i].second);
		for(int i = ans2.size() - 1; i >= 0; i--)
			printf("%d %d\n", ans2[i].first, ans2[i].second);
	}
	return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef pair <int, int> ii;

const int Maxn = 10005;
const int Maxb = 31;

struct linker {
	int x, y, id;
	linker(int x = 0, int y = 0, int id = 0): x(x), y(y), id(id) {}
	bool operator <(const linker &b) const {
		if (y != b.y) return y > b.y;
		if (x != b.x) return x > b.x;
		return id < b.id;
	}
};

int n;
linker L[Maxn];
int xbas[Maxb];
int rval[Maxb], masktaken[Maxn];
vector <ii> res;

int getBit(int x)
{
	if (x == 0) return -1;
	for (int i = Maxb - 1; i >= 0; i--)
		if (x & 1 << i) return i;
}

void Swap(int a, int b)
{
	if (a == b) return;
	res.push_back(ii(L[a].id, L[b].id));
	res.push_back(ii(L[b].id, L[a].id));
	res.push_back(ii(L[a].id, L[b].id));
	swap(L[a].x, L[b].x);
	int ab = getBit(L[a].x), bb = getBit(L[b].x);
	if (ab != -1) xbas[ab] = a;
	if (bb != -1) xbas[bb] = b;
}

void writeMask(int x)
{
	for (int i = 0; i < Maxb; i++)
		if (masktaken[L[x].id] & 1 << i)
			res.push_back(ii(L[x].id, rval[i]));
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &L[i].x); L[i].id = i;
		for (int b = Maxb - 1; b >= 0; b--)
			if (L[i].x & 1 << b)
				if (xbas[b]) { res.push_back(ii(i, xbas[b])); L[i].x ^= L[xbas[b]].x; }
				else { xbas[b] = i; break; }
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &L[i].y); int num = L[i].y; L[i].y = 0;
		for (int b = Maxb - 1; b >= 0; b--)
			if (num & 1 << b)
				if (xbas[b]) { num ^= L[xbas[b]].x; L[i].y |= 1 << b; }
				else { printf("-1\n"); return 0; }
	}
	int cur = 1;
	while (true) {
		sort(L + cur, L + n + 1);
		for (int i = cur; i <= n; i++) {
			int b = getBit(L[i].x);
			if (b != -1) xbas[b] = i;
		}
		int b = getBit(L[cur].y);
		if (b == -1) {
			for (int i = cur; i <= n; i++) {
				if (L[i].x) res.push_back(ii(L[i].id, L[i].id));
				writeMask(i);
			}
			break;
		} else {
			Swap(cur, xbas[b]);
			writeMask(cur);
			for (int i = b - 1; i >= 0; i--)
				if (L[cur].y & 1 << i) res.push_back(ii(L[cur].id, L[xbas[i]].id));
			rval[b] = L[cur].id; masktaken[L[cur].id] ^= 1 << b;
			for (int i = cur + 1; i <= n; i++)
				if (L[i].y & 1 << b) {
					L[i].y ^= L[cur].y;
					masktaken[L[i].id] ^= masktaken[L[cur].id];
				}
		}
		cur++;
	}
	printf("%d\n", res.size());
	for (int i = 0; i < res.size(); i++)
		printf("%d %d\n", res[i].first, res[i].second);
	return 0;
}


#include<bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
using namespace std;
const int M=10050,N=29;
int d[N+2],ind[M],b[N+2],x[M],y[M],dx[N+2],dy[M];
vector<pii> ans,t;
int n,cnt,s;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&x[i]);
	for(int i=1;i<=n;++i)
		scanf("%d",&y[i]);
	for(int i=1;i<=n;++i){
		ind[i]=-1;
		for(int j=N,s=0;j>=0;--j)
			if(x[i]>>j&1)
				if(d[j]) {
					x[i]^=x[d[j]];
					s^=dx[j];
				}
				else{
					ind[i]=j;
					d[j]=i;
					dx[j]=s|(1<<j);
					break;
				}
	}
	for(int i=1;i<=n;++i){
		s=0;
		for(int j=N;j>=0;--j)
			if(y[i]>>j&1)
				if(d[j]) {
					y[i]^=x[d[j]];
					s^=dx[j];
				}
				else {
					puts("-1");
					return 0;
				}
		if(ind[i]>=0) {
			b[cnt]=i;
			dy[cnt++]=s;
			continue;
		}
		ans.push_back(mp(i,i));
		for(int j=N;j>=0;--j)
			if(s>>j&1)
				ans.push_back(mp(i,d[j]));
	}
	for(int i=0;i<cnt;++i){
		int s=dy[i]; dy[i]=0;
		for(int j=0;j<cnt;++j)
			if(s>>ind[b[j]]&1)
				dy[i]|=1<<j;
	}
	for(int i=0;i<cnt;++i){
		if(!(dy[i]>>i&1))
			for(int j=i+1;j<cnt;++j)
				if(dy[j]>>i&1){
					t.push_back(mp(b[i],b[j]));
					t.push_back(mp(b[j],b[i]));
					t.push_back(mp(b[i],b[j]));
					swap(dy[i],dy[j]);
					break;
				}
		if(dy[i]>>i&1)
			for(int j=i+1;j<cnt;++j)
				if(dy[j]>>i&1){
					t.push_back(mp(b[j],b[i]));
					dy[j]^=dy[i];
				}
	}
	for(int i=0;i<cnt;++i){
		if(!(dy[i]>>i&1))
			ans.push_back(mp(b[i],b[i]));
		for(int j=i+1;j<cnt;++j)
			if(dy[i]>>j&1)
				ans.push_back(mp(b[i],b[j]));
	}
	reverse(t.begin(),t.end());
	for(auto v:t)
		ans.push_back(v);
	printf("%d\n",ans.size());
	for(auto v:ans)
		printf("%d %d\n",v.first,v.second);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
vector<P> myon;
template<typename T>
vector<T> Gauss_Jordan(const vector<T> &v, const int &MAX){ //v[i]<2^MAX
    int n=v.size();
    vector<T> ret=v;
    int d=0;
    for(int k=MAX-1; k>=0; k--){
        int p=-1;
        for(int i=d; i<n; i++){
            if((ret[i]>>k)&1){
                p=i;
                break;
            }
        }
        if(p==-1) continue;
		if(d!=p){
			myon.push_back({d, p});
			myon.push_back({p, d});
			myon.push_back({d, p});
		}
        swap(ret[d], ret[p]);
        for(int i=0; i<n; i++){
            if(i==d) continue;
            if((ret[i]>>k)&1){
				ret[i]^=ret[d];
				myon.push_back({i, d});
			}
        }
        d++;
    }
    return ret;
}
int main()
{
	int n;
	cin>>n;
	vector<int> x(n), y(n);
	for(int i=0; i<n; i++){
		cin>>x[i];
	}
	for(int i=0; i<n; i++){
		cin>>y[i];
	}
	vector<int> ret1=Gauss_Jordan(x, 30);
	vector<P> ans=myon;
	myon.clear();
	vector<int> ret2=Gauss_Jordan(y, 30);
	vector<int> v1, v2;
	for(int i=0; i<n; i++){
		if(ret1[i]==0) break;
		v1.push_back(ret1[i]);
	}
	for(int i=0; i<n; i++){
		if(ret2[i]==0) break;
		v2.push_back(ret2[i]);
	}
	for(int i=0; i<v2.size(); i++){
		int z=ret2[i];
		int p=-1;
		for(int j=0; j<v1.size(); j++){
			for(int k=29; k>=0; k--){
				if(ret1[j]&(1<<k)){
					if(z&(1<<k)){
						z^=ret1[j];
						if(p==-1) p=j;
						else{
							ans.push_back({p, j});
						}
					}
					break;
				}
			}
		}
		if(z){
			cout<<-1<<endl;
			return 0;
		}
		if(p!=i){
			ans.push_back({i, p});
			ans.push_back({p, i});
			ans.push_back({i, p});
		}
	}
	for(int i=v2.size(); i<v1.size(); i++){
		ans.push_back({i, i});
	}
	reverse(myon.begin(), myon.end());
	ans.insert(ans.end(), myon.begin(), myon.end());
	cout<<ans.size()<<endl;
	for(auto p:ans){
		printf("%d %d\n", p.first+1, p.second+1);
	}
	/*for(auto p:ans){
		x[p.first]^=x[p.second];
	}
	for(int i=0; i<n; i++){
		cerr<<x[i]<<" "<<y[i]<<endl;
	}*/
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 10007 , lglg = 31 , L = lglg + 2;

#define pick(a,b) (((a)>>(b))&1)
#define shl(a) (1<<(a))

inline void failure(){cout<<-1<<lf;exit(0);}

int n,px[_],py[_];
int gay[L]={0},isgay[_]={0},via[_]={0};
vector<pair<int,int>> ans,ans2;

inline void add(int a,int b){ans.emplace_back(a,b);}
inline void add2(int a,int b){ans2.emplace_back(a,b);}

int bs[_]={0},vs[_]={0},lps=0;

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty();
	for(int i=1;i<=n;i++)px[i]=ty();
	for(int i=1;i<=n;i++)py[i]=ty();

	for(int i=1;i<=n;i++)
	{
		isgay[i]=-1;
		for(int j=lglg,a=0;j>=0;j--)
		{
			if(!pick(px[i],j))continue;
			if(gay[j])px[i]^=px[gay[j]],a^=via[j];
			else{isgay[i]=j,gay[j]=i,via[j]=a|shl(j);break;}
		}
	}

	for(int i=1;i<=n;i++)
	{
		int a=0;
		for(int j=lglg;j>=0;j--)
		{
			if(!pick(py[i],j))continue;
			if(!gay[j])failure();
			py[i]^=px[gay[j]],a^=via[j];
		}
		if(isgay[i]>=0){bs[lps]=i,vs[lps]=a,lps++;continue;}
		add(i,i);
		for(int j=lglg;j>=0;j--)if(pick(a,j))add(i,gay[j]);
	}

	for(int i=0;i<lps;i++)
	{
		int a=vs[i];vs[i]=0;
		for(int j=0;j<lps;j++)
			if(pick(a,isgay[bs[j]]))vs[i]|=shl(j);
	}

	for(int i=0;i<lps;i++)
	{
		if(!pick(vs[i],i))
			for(int j=i+1;j<lps;j++)
				if(pick(vs[j],i)){add2(bs[i],bs[j]),add2(bs[j],bs[i]),add2(bs[i],bs[j]),swap(vs[i],vs[j]);break;}
		if(pick(vs[i],i))
			for(int j=i+1;j<lps;j++)
				if(pick(vs[j],i))add2(bs[j],bs[i]),vs[j]^=vs[i];
	}

	for(int i=0;i<lps;i++)
	{
		if(!pick(vs[i],i))add(bs[i],bs[i]);
		for(int j=i+1;j<lps;j++)if(pick(vs[i],j))add(bs[i],bs[j]);
	}

	reverse(ans2.begin(),ans2.end()),ans.insert(ans.end(),ans2.begin(),ans2.end());
	cout<<ans.size()<<lf;
	for(auto i:ans)cout<<i.first<<' '<<i.second<<lf;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = (int)1e4 + 11;
const int M = 33;
using pii = pair <int, int>;
using vpii = vector <pii>;

#define pb push_back
#define fi first
#define se second

int x[N], y[N];
int lb(int x) { return x & (-x); }

int y_comb[M];

vpii gauss(int x[], int n, int &b) {
	vpii ret;
	for(int i = 0; i < n; i ++) {
		for(int j = 0; j < b; j ++)
			if(lb(x[j]) & x[i]) {
				x[i] ^= x[j];
				ret.pb({i, j});
			}
		if(x[i]) {
			for(int j = 0; j < b; j ++)
				if(lb(x[i]) & x[j]) {
					x[j] ^= x[i];
					ret.pb({j, i});
				}
			if(i != b) {
				swap(x[i], x[b]);
				ret.pb({i, b});
				ret.pb({b, i});
				ret.pb({i, b});
			}
			b ++;
		}
	}
	return ret;
}

int p[M];

int cx[N];

int main() {
	ios :: sync_with_stdio(false);
	int n; cin >> n;
	for(int i = 0; i < n; i ++) { cin >> x[i]; cx[i] = x[i]; }
	for(int i = 0; i < n; i ++) cin >> y[i];
	int xb = 0, yb = 0;
	vpii p1 = gauss(x, n, xb);
	vpii p3 = gauss(y, n, yb);
	reverse(p3.begin(), p3.end());

	bool f = true;
	for(int i = 0; i < yb; i ++) {
		for(int j = 0; j < xb; j ++)
			if(lb(x[j]) & y[i]) {
				y[i] ^= x[j];
				y_comb[i] |= (1 << j);
			}
		if(y[i]) f = false;
	}
	if(!f) {
		cout << "-1\n";
		return 0;
	}

	vpii p2;
	iota(p, p + xb, 0);
	for(int i = 0; i < yb; i ++) {
		int now = y_comb[i];
		for(int j = 0; j < i; j ++)
			if((now >> p[j]) & 1) {
				now ^= y_comb[j];
				p2.pb({i, j});
			}
		int l = __builtin_ctz(now);
		if(p[i] != l) {
			int t = -1;
			for(int j = i + 1; j < xb; j ++)
				if(p[j] == l) t = j;
			swap(p[i], p[t]);
			p2.pb({i, t});
			p2.pb({t, i});
			p2.pb({i, t});
		}
		for(int j = i + 1; j < xb; j ++)
			if((now >> p[j]) & 1) {
				p2.pb({i, j});
			}
	}
	for(int i = yb; i < xb; i ++)
		p2.pb({i, i});

	cout << p1.size() + p2.size() + p3.size() << '\n';
	for(vpii v : {p1, p2, p3}) {
		for(pii p : v)
			cout << p.fi + 1 << ' ' << p.se + 1 << '\n';
		//cout << '\n';
	}

	/*
	auto check = [&](vpii v) {
		for(pii p : v)
			cx[p.fi] ^= cx[p.se];
	};
	check(p1); check(p2); check(p3);

	for(int i = 0; i < n; i ++)
		cout << cx[i] << ' ';
	cout << '\n';
	*/

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = (int)1e4 + 11;
const int M = 33;
using pii = pair <int, int>;
using vpii = vector <pii>;

#define pb push_back
#define fi first
#define se second

int x[N], y[N];
int lb(int x) { return x & (-x); }

int y_comb[M];

vpii gauss(int x[], int n, int &b) {
	vpii ret;
	for(int i = 0; i < n; i ++) {
		for(int j = 0; j < b; j ++)
			if(lb(x[j]) & x[i]) {
				x[i] ^= x[j];
				ret.pb({i, j});
			}
		if(x[i]) {
			for(int j = 0; j < b; j ++)
				if(lb(x[i]) & x[j]) {
					x[j] ^= x[i];
					ret.pb({j, i});
				}
			if(i != b) {
				swap(x[i], x[b]);
				ret.pb({i, b});
				ret.pb({b, i});
				ret.pb({i, b});
			}
			b ++;
		}
	}
	return ret;
}

int p[M];

int cx[N];

int main() {
	ios :: sync_with_stdio(false);
	int n; cin >> n;
	for(int i = 0; i < n; i ++) { cin >> x[i]; cx[i] = x[i]; }
	for(int i = 0; i < n; i ++) cin >> y[i];
	int xb = 0, yb = 0;
	vpii p1 = gauss(x, n, xb);
	vpii p3 = gauss(y, n, yb);

	bool f = true;
	for(int i = 0; i < yb; i ++) {
		for(int j = 0; j < xb; j ++)
			if(lb(x[j]) & y[i]) {
				y[i] ^= x[j];
				y_comb[i] |= (1 << j);
			}
		if(y[i]) f = false;
	}
	if(!f) {
		cout << "-1\n";
		return 0;
	}

	for(int i = 0; i < yb; i ++) {
		for(int j = 0; j < i; j ++)
			if(lb(y_comb[j]) & y_comb[i]) {
				y_comb[i] ^= y_comb[j];
				p3.pb({i, j});
			}
		for(int j = 0; j < i; j ++)
			if(lb(y_comb[i]) & y_comb[j]) {
				y_comb[j] ^= y_comb[i];
				p3.pb({j, i});
			}
	}
	reverse(p3.begin(), p3.end());

	vpii p2;
	iota(p, p + xb, 0);
	for(int i = 0; i < yb; i ++) {
		int now = y_comb[i];
		for(int j = 0; j < i; j ++)
			if((now >> p[j]) & 1) {
				now ^= y_comb[j];
				p2.pb({i, j});
			}
		int l = __builtin_ctz(now);
		if(p[i] != l) {
			int t = -1;
			for(int j = i + 1; j < xb; j ++)
				if(p[j] == l) t = j;
			swap(p[i], p[t]);
			p2.pb({i, t});
			p2.pb({t, i});
			p2.pb({i, t});
		}
		for(int j = i + 1; j < xb; j ++)
			if((now >> p[j]) & 1) {
				p2.pb({i, j});
				now ^= (1 << p[j]);
			}
	}
	for(int i = yb; i < xb; i ++)
		p2.pb({i, i});

	cout << p1.size() + p2.size() + p3.size() << '\n';
	for(vpii v : {p1, p2, p3}) {
		for(pii p : v)
			cout << p.fi + 1 << ' ' << p.se + 1 << '\n';
		//cout << '\n';
	}

	/*
	auto check = [&](vpii v) {
		for(pii p : v)
			cx[p.fi] ^= cx[p.se];
	};
	check(p1); check(p2); check(p3);

	for(int i = 0; i < n; i ++)
		cout << cx[i] << ' ';
	cout << '\n';
	*/

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = (int)1e4 + 11;
const int M = 33;
using pii = pair <int, int>;
using vpii = vector <pii>;

#define pb push_back
#define fi first
#define se second

int x[N], y[N];
int lb(int x) { return x & (-x); }

int y_comb[M];

vpii gauss(int x[], int n, int &b) {
	vpii ret;
	for(int i = 0; i < n; i ++) {
		for(int j = 0; j < b; j ++)
			if(lb(x[j]) & x[i]) {
				x[i] ^= x[j];
				ret.pb({i, j});
			}
		if(x[i]) {
			for(int j = 0; j < b; j ++)
				if(lb(x[i]) & x[j]) {
					x[j] ^= x[i];
					ret.pb({j, i});
				}
			if(i != b) {
				swap(x[i], x[b]);
				ret.pb({i, b});
				ret.pb({b, i});
				ret.pb({i, b});
			}
			b ++;
		}
	}
	return ret;
}

int p[M];

int cx[N];

int main() {
	ios :: sync_with_stdio(false);
	int n; cin >> n;
	for(int i = 0; i < n; i ++) { cin >> x[i]; cx[i] = x[i]; }
	for(int i = 0; i < n; i ++) cin >> y[i];
	int xb = 0, yb = 0;
	vpii p1 = gauss(x, n, xb);
	vpii p3 = gauss(y, n, yb);
	reverse(p3.begin(), p3.end());

	bool f = true;
	for(int i = 0; i < yb; i ++) {
		for(int j = 0; j < xb; j ++)
			if(lb(x[j]) & y[i]) {
				y[i] ^= x[j];
				y_comb[i] |= (1 << j);
			}
		if(y[i]) f = false;
	}
	if(!f) {
		cout << "-1\n";
		return 0;
	}

	vpii p2;
	iota(p, p + xb, 0);
	for(int i = 0; i < yb; i ++) {
		int now = y_comb[i];
		for(int j = 0; j < i; j ++)
			if((now >> p[j]) & 1) {
				now ^= y_comb[j];
				p2.pb({i, j});
			}
		int l = __builtin_ctz(now);
		if(p[l] != i) {
			swap(p[l], p[i]);
			p2.pb({l, i});
			p2.pb({i, l});
			p2.pb({l, i});
		}
		for(int j = i + 1; j < xb; j ++)
			if((now >> p[j]) & 1) {
				p2.pb({i, j});
			}
	}
	for(int i = yb; i < xb; i ++)
		p2.pb({i, i});

	cout << p1.size() + p2.size() + p3.size() << '\n';
	for(vpii v : {p1, p2, p3}) {
		for(pii p : v)
			cout << p.fi + 1 << ' ' << p.se + 1 << '\n';
		//cout << '\n';
	}

	/*
	auto check = [&](vpii v) {
		for(pii p : v)
			cx[p.fi] ^= cx[p.se];
	};
	check(p1); check(p2); check(p3);

	for(int i = 0; i < n; i ++)
		cout << cx[i] << ' ';
	cout << '\n';
	*/

	return 0;
}


#include <bits/stdc++.h>
#define lg2 std::__lg
#define ctz __builtin_ctz
using std::cin;
using std::cout;

typedef unsigned int u32;
typedef std::pair <int, int> pr;
const int N = 10054;

int n, rank = 0, ans_len = 0, bak_len = 0;
int idp[32], pos[N];
u32 x[N], y[N], z[N];
pr ans[2003731], bak[2003731];

namespace linear {
	u32 lb[32], wb[32];

	inline bool insert(u32 x, u32 w) {
		for (int i; x; )
			if (lb[i = lg2(x)]) x ^= lb[i], w ^= wb[i];
			else return lb[i] = x, wb[i] = w, true;
		return false;
	}

	inline bool represent(u32 x) {
		for (int i; x; )
			if (lb[i = lg2(x)]) x ^= lb[i];
			else return false;
		return true;
	}

	inline u32 find_represent(u32 x) {
		u32 r = 0;
		for (int i; x; )
			if (lb[i = lg2(x)]) x ^= lb[i], r ^= wb[i];
			else throw "linear independent !";
		return r;
	}
}

inline void Xor_eq(int x, int y) {ans[ans_len++] = pr(x, y);}
inline void elim(int x, int y) {bak[bak_len++] = pr(idp[x], idp[y]);}
inline void swap(int x, int y) {if (x != y) elim(x, y), elim(y, x), elim(x, y);}

int main() {
	int i, j, k; u32 coef;
	std::ios::sync_with_stdio(false), cin.tie(NULL);
	cin >> n;
	for (i = 0; i < n; ++i)
		if (pos[i] = -1, cin >> x[i], !linear::represent(x[i]))
			idp[rank] = i, pos[i] = rank,
			linear::insert(x[i], 1u << rank++);
	for (i = 0; i < n; ++i)
		if (cin >> y[i], !linear::represent(y[i])) return cout << "-1\n", 0;
	for (i = 0; i < n; ++i) if (!~pos[i])
		for (coef = linear::find_represent(x[i] ^ y[i]); coef; coef &= coef - 1)
			Xor_eq(i, idp[ctz(coef)]);
	for (j = 0; j < rank; ++j) i = idp[j], z[j] = linear::find_represent(y[i]);
	for (k = i = 0; i < rank; ++i) {
		for (j = k; j < rank && ~z[j] >> i & 1; ++j);
		if (j == rank) continue;
		swap(k, j), std::swap(z[k], z[j]);
		for (j = 0; j < rank; ++j) if (j != k && z[j] >> i & 1) elim(j, k), z[j] ^= z[k];
		++k;
	}
	for (i = 0; i < rank; ++i)
		for (coef = z[i] ^ (1u << i); coef; coef &= coef - 1)
			Xor_eq(idp[i], idp[ctz(coef)]);
	ans_len = std::reverse_copy(bak, bak + bak_len, ans + ans_len) - ans,
	cout << ans_len << '\n';
	for (i = 0; i < ans_len; ++i) cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << '\n';
	return 0;
}


#include <bits/stdc++.h>
#define lg2 std::__lg
#define ctz __builtin_ctz
using std::cin;
using std::cout;

typedef unsigned int u32;
typedef std::pair <int, int> pr;
const int N = 10054;

int n, rank = 0, ans_len = 0, bak_len = 0;
int idp[32], pos[N];
u32 x[N], y[N], z[N];
pr ans[2003731], bak[2003731];

namespace linear {
	u32 lb[32], wb[32];

	inline bool insert(u32 x, u32 w) {
		for (int i; x; )
			if (lb[i = lg2(x)]) x ^= lb[i], w ^= wb[i];
			else return lb[i] = x, wb[i] = w, true;
		return false;
	}

	inline bool represent(u32 x) {
		for (int i; x; )
			if (lb[i = lg2(x)]) x ^= lb[i];
			else return false;
		return true;
	}

	inline u32 find_represent(u32 x) {
		u32 r = 0;
		for (int i; x; )
			if (lb[i = lg2(x)]) x ^= lb[i], r ^= wb[i];
			else throw "linear independent !";
		return r;
	}
}

inline void Xor_eq(int x, int y) {ans[ans_len++] = pr(x, y);}
inline void elim(int x, int y) {bak[bak_len++] = pr(idp[x], idp[y]);}
inline void swap(int x, int y) {if (x != y) elim(x, y), elim(y, x), elim(x, y);}

int main() {
	int i, j, k; u32 coef;
	std::ios::sync_with_stdio(false), cin.tie(NULL);
	cin >> n;
	for (i = 0; i < n; ++i)
		if (pos[i] = -1, cin >> x[i], !linear::represent(x[i]))
			idp[rank] = i, pos[i] = rank,
			linear::insert(x[i], 1u << rank++);
	for (i = 0; i < n; ++i)
		if (cin >> y[i], !linear::represent(y[i])) return cout << "-1\n", 0;
	for (i = 0; i < n; ++i) if (!~pos[i])
		for (coef = linear::find_represent(x[i] ^ y[i]); coef; coef &= coef - 1)
			Xor_eq(i, idp[ctz(coef)]);
	for (j = 0; j < rank; ++j) i = idp[j], z[j] = linear::find_represent(y[i]);
	for (k = i = 0; i < rank; ++i) {
		for (j = k; j < rank && ~z[j] >> i & 1; ++j);
		if (j == rank) continue;
		swap(i, j), std::swap(z[i], z[j]), ++k;
		for (j = 0; j < rank; ++j) if (j != i && z[j] >> i & 1) elim(j, i), z[j] ^= z[i];
	}
	for (i = 0; i < rank; ++i)
		for (coef = z[i] ^ (1u << i); coef; coef &= coef - 1)
			Xor_eq(idp[i], idp[ctz(coef)]);
	ans_len = std::reverse_copy(bak, bak + bak_len, ans + ans_len) - ans,
	cout << ans_len << '\n';
	for (i = 0; i < ans_len; ++i) cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << '\n';
	return 0;
}


#include <bits/stdc++.h>
#define lg2 std::__lg
#define ctz __builtin_ctz
using std::cin;
using std::cout;

typedef unsigned int u32;
typedef std::pair <int, int> pr;
const int N = 10054;

int n, rank = 0, ans_len = 0, bak_len = 0;
int idp[32], pos[N];
u32 x[N], y[N], z[N];
pr ans[2003731], bak[2003731];

namespace linear {
	u32 lb[32], wb[32];

	inline bool insert(u32 x, u32 w) {
		for (int i; x; )
			if (lb[i = lg2(x)]) x ^= lb[i], w ^= wb[i];
			else return lb[i] = x, wb[i] = w, true;
		return false;
	}

	inline bool represent(u32 x) {
		for (int i; x; )
			if (lb[i = lg2(x)]) x ^= lb[i];
			else return false;
		return true;
	}

	inline u32 find_represent(u32 x) {
		u32 r = 0;
		for (int i; x; )
			if (lb[i = lg2(x)]) x ^= lb[i], r ^= wb[i];
			else throw "linear independent !";
		return r;
	}
}

inline void Xor_eq(int x, int y) {ans[ans_len++] = pr(x, y);}
inline void elim(int x, int y) {bak[bak_len++] = pr(idp[x], idp[y]);}
inline void swap(int x, int y) {if (x != y) elim(x, y), elim(y, x), elim(x, y);}

int main() {
	int i, j; u32 coef;
	std::ios::sync_with_stdio(false), cin.tie(NULL);
	cin >> n;
	for (i = 0; i < n; ++i)
		if (pos[i] = -1, cin >> x[i], !linear::represent(x[i]))
			idp[rank] = i, pos[i] = rank,
			linear::insert(x[i], 1u << rank++);
	for (i = 0; i < n; ++i)
		if (cin >> y[i], !linear::represent(y[i])) return cout << "-1\n", 0;
	for (i = 0; i < n; ++i) if (!~pos[i])
		for (coef = linear::find_represent(x[i] ^ y[i]); coef; coef &= coef - 1)
			Xor_eq(i, idp[ctz(coef)]);
	for (j = 0; j < rank; ++j) i = idp[j], z[j] = linear::find_represent(y[i]);
	for (i = 0; i < rank; ++i) {
		for (j = i; j < rank && ~z[j] >> i & 1; ++j);
		if (j == rank) continue;
		swap(i, j), std::swap(z[i], z[j]);
		for (j = 0; j < rank; ++j) if (j != i && z[j] >> i & 1) elim(j, i), z[j] ^= z[i];
	}
	for (i = 0; i < rank; ++i)
		if (z[i] >> i & 1)
			for (coef = z[i] & (-2 << i); coef; coef &= coef - 1)
				Xor_eq(idp[i], idp[ctz(coef)]);
		else
			assert(!z[i]), Xor_eq(idp[i], idp[i]);
	ans_len = std::reverse_copy(bak, bak + bak_len, ans + ans_len) - ans,
	cout << ans_len << '\n';
	for (i = 0; i < ans_len; ++i) cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << '\n';
	return 0;
}


import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * Created by Darren on 14-9-29.
 */
public class Main {
    Reader in = new Reader(System.in);
    PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() throws IOException {
        int n = in.nextInt();
        LinearSpace x = new LinearSpace(n), y = new LinearSpace(n);
        x.adjust(y);
        if (!x.sameSpace(y))
            out.println(-1);
        else {
            out.println(x.getOperationSize()+y.getOperationSize());
            x.outputOperations(false);
            y.outputOperations(true);
        }
        out.flush();
    }

    class LinearSpace {
        final int MAX_SHIFT = 30;

        int[] data;
        int n;
        int rank;
        List<Operators> operations;

        public LinearSpace(int n) throws IOException {
            this.n = n;
            rank = 0;
            data = new int[n];
            for (int i = 0; i < n; i++)
                data[i] = in.nextInt();
            operations = new ArrayList<Operators>();
            gaussian();
        }

        void gaussian() {
            rank = 0;
            operations.clear();

            for (int shift = MAX_SHIFT; shift >= 0; shift--) {
                int mainRowID = -1;
                for (int i = rank; i < n; i++) {
                    if (((data[i] >> shift) & 1) == 1) {
                        mainRowID = i;
                        break;
                    }
                }
                if (mainRowID != -1) {
                    if (mainRowID != rank)
                        swap(mainRowID, rank);
                    for (int j = rank+1; j < n; j++) {
                        if (((data[j] >> shift) & 1) == 1)
                            eliminate(j, rank);
                    }
                    rank++;
                }
            }
        }

        void swap(int x, int y) {
            operations.add(new Operators(x, y));
            operations.add(new Operators(y, x));
            operations.add(new Operators(x, y));
            data[x] ^= data[y];
            data[y] ^= data[x];
            data[x] ^= data[y];
        }

        void eliminate(int x, int y) {
            operations.add(new Operators(x, y));
            data[x] ^= data[y];
        }

        void adjust(final LinearSpace another) {
            int maxRank = Math.max(this.rank, another.rank);
            int shift = MAX_SHIFT;
            for (int i = 0; i < rank; i++) {
                while (((data[i] >> shift) & 1) == 0)
                    shift--;
                for (int j = 0; j < maxRank; j++) {
                    if (((data[j] >> shift) & 1) != ((another.data[j] >> shift) & 1))
                        eliminate(j, i);
                }
            }
        }

        boolean sameSpace(final LinearSpace another) {
            int maxRank = Math.max(this.rank, another.rank);
            for (int i = 0; i < maxRank; i++) {
                if (data[i] != another.data[i])
                    return false;
            }
            return true;
        }

        int getOperationSize() {
            return operations.size();
        }

        void outputOperations(boolean reverse) {
            if (reverse) {
                for (int i = operations.size()-1; i >= 0; i--) {
                    out.print(operations.get(i).x + 1);
                    out.print(' ');
                    out.println(operations.get(i).y + 1);
                }
            } else {
                for (int i = 0; i < operations.size(); i++) {
                    out.print(operations.get(i).x + 1);
                    out.print(' ');
                    out.println(operations.get(i).y + 1);
                }
            }
        }

        class Operators {
            int x;
            int y;

            public Operators(int x, int y) {
                this.x = x;
                this.y = y;
            }
        }
    }

    static class Reader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public Reader(InputStream input) {
            reader = new BufferedReader(new InputStreamReader(input));
            tokenizer = new StringTokenizer("");
        }

        /** get next word */
        String nextToken() throws IOException {
            while ( ! tokenizer.hasMoreTokens() ) {
                //TODO add check for eof if necessary
                tokenizer = new StringTokenizer( reader.readLine() );
            }
            return tokenizer.nextToken();
        }

        String readLine() throws IOException {
            return reader.readLine();
        }

        int nextInt() throws IOException {
            return Integer.parseInt( nextToken() );
        }

        long nextLong() throws IOException {
            return Long.parseLong( nextToken() );
        }

        double nextDouble() throws IOException {
            return Double.parseDouble( nextToken() );
        }
    }
}


import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * CodeForces 472F - Design Tutorial: Change the Goal
 * Created by Darren on 14-9-29.
 * O(n^2) time and O(n^2) space.
 *
 * Tag: linear algebra, xor
 */
public class Main {
    Reader in = new Reader(System.in);
    PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() throws IOException {
        int n = in.nextInt();
        LinearSpace x = new LinearSpace(n), y = new LinearSpace(n);
        if (!x.transformable(y))
            out.println(-1);
        else {
            out.println(x.getOperationSize()+y.getOperationSize());
            x.outputOperations(false);
            y.outputOperations(true);
        }
        out.flush();
    }

    // Class LinearSpace
    class LinearSpace {
        final int MAX_SHIFT = 31;   // Regular int range

        int[] data;
        int n;
        int rank;   // Rank of the linear space
        List<Operands> operations; // Used to store history of XOR operations

        public LinearSpace(int n) throws IOException {
            this.n = n;
            rank = 0;
            data = new int[n];
            for (int i = 0; i < n; i++)
                data[i] = in.nextInt();
            operations = new ArrayList<Operands>();
            gaussian();
        }

        // Conduct Gaussian elimination
        void gaussian() {
            rank = 0;
            operations.clear();

            for (int shift = MAX_SHIFT; shift >= 0; shift--) {
                // Find the index of the value whose bit at the given shift is one; this value is
                // used as a base of the linear space
                int mainRowID = -1;
                for (int i = rank; i < n; i++) {
                    if (((data[i] >> shift) & 1) == 1) {
                        mainRowID = i;
                        break;
                    }
                }

                // Such value exists
                if (mainRowID != -1) {
                    if (mainRowID != rank)
                        // Swap the value such that it is on the left hand side
                        // togher with otherbases
                        swap(mainRowID, rank);

                    // Clear the 1's at the given shift for the remaining values
                    for (int j = rank+1; j < n; j++) {
                        if (((data[j] >> shift) & 1) == 1)
                            eliminate(j, rank);
                    }
                    rank++;
                }
            }
        }

        // Swap data[p] and data[q]
        void swap(int p, int q) {
            operations.add(new Operands(p, q));
            operations.add(new Operands(q, p));
            operations.add(new Operands(p, q));
            data[p] ^= data[q];
            data[q] ^= data[p];
            data[p] ^= data[q];
        }

        // data[p] ^= data[q]
        void eliminate(int p, int q) {
            operations.add(new Operands(p, q));
            data[p] ^= data[q];
        }

        boolean transformable(final LinearSpace another) {
            if (rank < another.rank)
                return false;

            // Adjust the bases to those of another linear space.
            int shift = MAX_SHIFT;
            for (int i = 0; i < rank; i++) {
                // Find data[i] such that its bit at the given shift is 1
                while (((data[i] >> shift) & 1) == 0)
                    shift--;

                // Align the bases to those of the other space at the given shift
                for (int j = 0; j < rank; j++) {
                    if (((data[j] >> shift) & 1) != ((another.data[j] >> shift) & 1))
                        eliminate(j, i);
                }
            }

            // If the other space is the same with, or a subspace of, this space,
            // their first maxRank elements should be the same after the adjustment.
            for (int i = 0; i < rank; i++) {
                if (data[i] != another.data[i])
                    return false;
            }
            return true;
        }

        int getOperationSize() {
            return operations.size();
        }

        // Output operation history from oldest to newest if reverse is false,
        // or from newest to oldest if otherwise
        void outputOperations(boolean reverse) {
            if (reverse) {
                for (int i = operations.size()-1; i >= 0; i--) {
                    out.print(operations.get(i).p + 1);
                    out.print(' ');
                    out.println(operations.get(i).q + 1);
                }
            } else {
                for (int i = 0; i < operations.size(); i++) {
                    out.print(operations.get(i).p + 1);
                    out.print(' ');
                    out.println(operations.get(i).q + 1);
                }
            }
        }

        // Class Operators: (p,q) means x_p ^= x_q
        class Operands {
            int p;
            int q;

            public Operands(int p, int q) {
                this.p = p;
                this.q = q;
            }
        }
    }

    static class Reader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public Reader(InputStream input) {
            reader = new BufferedReader(new InputStreamReader(input));
            tokenizer = new StringTokenizer("");
        }

        /** get next word */
        String nextToken() throws IOException {
            while ( ! tokenizer.hasMoreTokens() ) {
                //TODO add check for eof if necessary
                tokenizer = new StringTokenizer( reader.readLine() );
            }
            return tokenizer.nextToken();
        }

        String readLine() throws IOException {
            return reader.readLine();
        }

        int nextInt() throws IOException {
            return Integer.parseInt( nextToken() );
        }

        long nextLong() throws IOException {
            return Long.parseLong( nextToken() );
        }

        double nextDouble() throws IOException {
            return Double.parseDouble( nextToken() );
        }
    }
}


import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		new Task().solve(1,in,out);
		out.close();
	}
}

class Task {
	void solve(int ca,InputReader in,PrintWriter out) {
		int n = in.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < n; ++ i) {
			A[i] = in.nextInt();
		}
		ArrayList<Pair> listA = new ArrayList<Pair>();
		gauss(A,listA);
		int[] B = new int[n];
		for (int i = 0; i < n; ++ i) {
			B[i] = in.nextInt();
		}
		ArrayList<Pair> listB = new ArrayList<Pair>();
		gauss(B,listB);
		int na = 0;
		for ( ; na < n && A[na] != 0; ++ na);
		int nb = 0;
		for ( ; nb < n && B[nb] != 0; ++ nb);
		for (int i = 0; i < nb; ++ i) {
			boolean flag = false;
			for (int j = 0; j < na; ++ j) {
				if (B[i] == A[j]) {
					if (i != j) {
						A[j] ^= A[i]; A[i] ^= A[j]; A[j] ^= A[i];
						listA.add(new Pair(j,i));
						listA.add(new Pair(i,j));
						listA.add(new Pair(j,i));
					}
					flag = true;
					break;
				}
			}
			if (!flag) {
				out.println(-1);
				return ;
			}
		}
		for (int i = nb; i < na; ++ i) {
			A[i] ^= A[i];
			listA.add(new Pair(i,i));
		}
		out.println((listA.size() + listB.size()));
		for (Pair t : listA) {
			t.a ++; t.b ++;
			out.println(t.a + " " + t.b);
		}
		for (int i = listB.size()-1; i >= 0; -- i) {
			Pair t = listB.get(i);
			t.a ++; t.b ++;
			out.println(t.a + " " + t.b);
		}
	}

	void gauss(int[] A,ArrayList<Pair> list) {
		int col = 29,row = 0;
		int n = A.length;
		while (col>=0 && row<n) {
			int mx = -1,p = -1;
			for (int i = row; i < n; ++ i) {
				if (A[i] > mx) {
					mx = A[i];
					p = i;
				}
			}
			if (mx == 0) break;
			if (p == -1) throw new RuntimeException();
			if (row != p) {
				A[p] ^= A[row]; A[row] ^= A[p]; A[p] ^= A[row];
				list.add(new Pair(p,row));
				list.add(new Pair(row,p));
				list.add(new Pair(p,row));
			}
			while (col>0 && (1<<col)>mx) -- col;
			for (int i = row+1; i < n; ++ i) {
				if ((1<<col) <= A[i]) {
					A[i] ^= A[row];
					list.add(new Pair(i,row));
				}
			}
			++ row;
			-- col;
		}
		for (int i = row-1; i >= 0; -- i) {
			int pos = 0;
			while ((A[i]>>pos&1) != 1) pos ++;
			for (int j = 0; j < i; ++ j) {
				if ((A[j]>>pos&1) == 1) {
					A[j] ^= A[i];
					list.add(new Pair(j,i));
				}
			}
		}
	}

	class Pair {
		int a,b;
		Pair(int a,int b) {
			this.a = a;
			this.b = b;
		}
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream),32768);
		tokenizer = null;
	}
	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
}


import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		new Task().solve(1,in,out);
		out.close();
	}
}

class Task {
	void solve(int ca,InputReader in,PrintWriter out) {
		int n = in.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < n; ++ i) {
			A[i] = in.nextInt();
		}
		ArrayList<Pair> listA = new ArrayList<Pair>();
		gauss(A,listA);
		int[] B = new int[n];
		for (int i = 0; i < n; ++ i) {
			B[i] = in.nextInt();
		}
		ArrayList<Pair> listB = new ArrayList<Pair>();
		gauss(B,listB);
		int na = 0;
		for ( ; na < n && A[na] != 0; ++ na);
		int nb = 0;
		for ( ; nb < n && B[nb] != 0; ++ nb);
		for (int i = 0; i < nb; ++ i) {
			boolean flag = false;
			for (int j = 0; j < na; ++ j) {
				if (B[i] == A[j]) {
					A[j] ^= A[i]; A[i] ^= A[j]; A[j] ^= A[i];
					listA.add(new Pair(j,i));
					listA.add(new Pair(i,j));
					listA.add(new Pair(j,i));
					flag = true;
					break;
				}
			}
			if (!flag) {
				out.println(-1);
				return ;
			}
		}
		for (int i = nb; i < na; ++ i) {
			A[i] ^= A[i];
			listA.add(new Pair(i,i));
		}
		out.println((listA.size() + listB.size()));
		for (Pair t : listA) {
			t.a ++; t.b ++;
			out.println(t.a + " " + t.b);
		}
		for (int i = listB.size()-1; i >= 0; -- i) {
			Pair t = listB.get(i);
			t.a ++; t.b ++;
			out.println(t.a + " " + t.b);
		}
	}

	void gauss(int[] A,ArrayList<Pair> list) {
		int col = 29,row = 0;
		int n = A.length;
		while (col>=0 && row<n) {
			int mx = -1,p = -1;
			for (int i = row; i < n; ++ i) {
				if (A[i] > mx) {
					mx = A[i];
					p = i;
				}
			}
			if (mx == 0) break;
			if (p == -1) throw new RuntimeException();
			if (row != p) {
				A[p] ^= A[row]; A[row] ^= A[p]; A[p] ^= A[row];
				list.add(new Pair(p,row));
				list.add(new Pair(row,p));
				list.add(new Pair(p,row));
			}
			while (col>0 && (1<<col)>mx) -- col;
			for (int i = row+1; i < n; ++ i) {
				if ((1<<col) <= A[i]) {
					A[i] ^= A[row];
					list.add(new Pair(i,row));
				}
			}
			++ row;
			-- col;
		}
		for (int i = row-1; i >= 0; -- i) {
			int pos = 0;
			while ((A[i]>>pos&1) != 1) pos ++;
			for (int j = 0; j < i; ++ j) {
				if ((A[j]>>pos&1) == 1) {
					A[j] ^= A[i];
					list.add(new Pair(j,i));
				}
			}
		}
	}

	class Pair {
		int a,b;
		Pair(int a,int b) {
			this.a = a;
			this.b = b;
		}
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream),32768);
		tokenizer = null;
	}
	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
}


import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		new Task().solve(1,in,out);
		out.close();
	}
}

class Task {
	void solve(int ca,InputReader in,PrintWriter out) {
		int n = in.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < n; ++ i) {
			A[i] = in.nextInt();
		}
		ArrayList<Pair> listA = new ArrayList<Pair>();
		gauss(A,listA);
		int[] B = new int[n];
		for (int i = 0; i < n; ++ i) {
			B[i] = in.nextInt();
		}
		ArrayList<Pair> listB = new ArrayList<Pair>();
		gauss(B,listB);
		int na = 0;
		for ( ; na<n && A[na]>0; ++ na);
		int nb = 0;
		for ( ; nb<n && B[nb]>0; ++ nb);
		for (int i = 0,r = 0; i < nb; ++ i) {
			int value = B[i];
			int p = -1;
			for ( ; r < na; ++ r) {
				if ((A[r]&-A[r]) == (value&-value)) {
					p = r ++;
					break;
				}
			}
			if (p == -1) {
				out.println(-1);
				return ;
			}
			value ^= A[p];
			for (int j = p+1; j<na && value>0; ++ j) {
				if ((value&-value) == (A[j]&-A[j])) {
					value ^= A[j];
					listA.add(new Pair(p,j));
				}
			}
			if (value != 0) {
				out.println(-1);
				return ;
			}
			A[p] = B[i];
		}
		for (int i = 0; i < nb; ++ i) {
			for (int j = 0; j < na; ++ j) {
				if (B[i] == A[j]) {
					if (i != j) {
						A[i] ^= A[j]; A[j] ^= A[i]; A[i] ^= A[j];
						listA.add(new Pair(i,j));
						listA.add(new Pair(j,i));
						listA.add(new Pair(i,j));
					}
					break;
				}
			}
		}
		for (int i = nb; i < na; ++ i) {
			A[i] ^= A[i];
			listA.add(new Pair(i,i));
		}
		out.println((listA.size() + listB.size()));
		for (Pair t : listA) {
			t.a ++; t.b ++;
			out.println(t.a + " " + t.b);
		}
		for (int i = listB.size()-1; i >= 0; -- i) {
			Pair t = listB.get(i);
			t.a ++; t.b ++;
			out.println(t.a + " " + t.b);
		}
	}

	void gauss(int[] A,ArrayList<Pair> list) {
		int row = 0;
		int n = A.length;
		while (row<n) {
			int mx = (1<<31)-1,p = -1;
			for (int i = row; i < n; ++ i) {
				int t = A[i]&-A[i];
				if (t>0 && t<mx) {
					mx = t;
					p = i;
				}
			}
			if (p == -1) break;
			if (row != p) {
				A[p] ^= A[row]; A[row] ^= A[p]; A[p] ^= A[row];
				list.add(new Pair(p,row));
				list.add(new Pair(row,p));
				list.add(new Pair(p,row));
			}
			for (int i = row+1; i < n; ++ i) {
				if ((A[i]&-A[i]) == mx) {
					A[i] ^= A[row];
					list.add(new Pair(i,row));
				}
			}
			++ row;
		}
	}

	class Pair {
		int a,b;
		Pair(int a,int b) {
			this.a = a;
			this.b = b;
		}
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream),32768);
		tokenizer = null;
	}
	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class F {

    private int[] s;
    private int k;
    private int[] x;
    private int zzz;

    private void solve() throws IOException {
        int n = nextInt();
        x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = nextInt();
        }
        int[] y = new int[n];
        for (int i = 0; i < n; i++) {
            y[i] = nextInt();
        }
        s = new int[50];
        k = 0;
        for (int i = 0; i < n; i++) {
            if (x[i] > 0 && !canMake(x[i])) {
                s[k++] = i;
            }
        }
        for (int i = 0; i < n; i++) {
            if (!canMake(y[i])) {
//                System.err.println(y[i]);
                out.println(-1);
                return;
            }
        }
        for (int i = 0; i < n; i++) {
            boolean ok = true;
            for (int j = 0; j < k; j++) {
                if (s[j] == i) ok = false;
            }
            if (ok) {
                move(i, i);
                canMake(y[i]);
                for (int j = 0; j < k; j++) {
                    if (bit(zzz, j)) {
                        move(i, s[j]);
                    }
                }
            }
        }
        int[] a = new int[k];
        for (int i = 0; i < k; i++) {
            canMake(y[s[i]]);
            a[i] = zzz;
        }
//        for (int i = 0; i < k; i++) {
//            for (int i = 0; i )
//        }
        int c1 = mn;
        for (int i = 0; i < k; i++) {
            for (int t = i; t < k; t++) {
                if (bit(a[t], i)) {
                    if (t != i) {
                        move(s[i], s[t]);
                        a[i] ^= a[t];
                    }
                    for (int j = 0; j < k; j++) {
                        if (i != j && bit(a[j], i)) {
                            move(s[j], s[i]);
                            a[j] ^= a[i];
                        }
                    }
                    break;
                }
            }
        }
        int c2 = mn;
        for (int i = 0; i < k; i++) {
            if (!bit(a[i], i)) {
                for (int j = 0; j < k; j++) {
                    if (bit(a[j], i)) {
                        move(s[j], s[i]);
                    }
                }
                move(s[i], s[i]);
            }
        }
//
//        for (int i = 0; i < mn; i++) {
//            x[moves[0][i]] ^= x[moves[1][i]];
//        }
//        for (int i = 0; i < n; i++) {
//            if (x[i] != y[i]){
//                System.out.println(Arrays.toString(x) + " " + Arrays.toString(y));
//                break;
//            }
//        }
//        System.out.println(ll);
        out.println(mn);
        for (int i = 0; i < c1; i++) {
            out.println((moves[0][i] + 1) + " " + (moves[1][i] + 1));
            x[moves[0][i]] ^= x[moves[1][i]];
        }
//        out.println();
        for (int i = c2; i < mn; i++) {
            out.println((moves[0][i] + 1) + " " + (moves[1][i] + 1));
            x[moves[0][i]] ^= x[moves[1][i]];
        }
//        out.println();
        for (int i = c2 - 1; i >= c1; i--) {
            out.println((moves[0][i] + 1) + " " + (moves[1][i] + 1));
            x[moves[0][i]] ^= x[moves[1][i]];
        }
        for (int i = 0; i < n; i++) {
            if (x[i] != y[i]) {
                throw new RuntimeException();
            }
        }
    }

    int[][] moves = new int[2][1000000];
    int mn;

    private void move(int i, int j) {
        moves[0][mn] = i;
        moves[1][mn] = j;
        mn++;
    }

    private boolean canMake(int z) {
        int[] q = new int[k + 1];
        int[] w = new int[k + 1];
        boolean[] zz = new boolean[k + 1];
        for (int i = 0; i < k; i++) {
            q[i] = x[s[i]];
            w[i] = (1 << i);
        }
        q[k] = z;
        for (int j = 0; j < 31; j++) {
            int t = 0;
            while (t < k && (zz[t] || !bit(q[t], j))) t++;
            if (t < k) {
                zz[t] = true;
                for (int i = 0; i <= k; i++) {
                    if (i != t && bit(q[i], j)) {
                        q[i] ^= q[t];
                        w[i] ^= w[t];
                    }
                }
            }
        }
        zzz = w[k];
        return q[k] == 0;
    }

    private boolean bit(int i, int j) {
        return ((i >> j) & 1) == 1;
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public static void main(String[] args) throws IOException {
        new F().run();
    }

    private void run() throws IOException {
        solve();
        out.close();
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class F {

    private int[] s;
    private int k;
    private int[] x;
    private int zzz;

    private void solve() throws IOException {
        int n = nextInt();
        x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = nextInt();
        }
        int[] y = new int[n];
        for (int i = 0; i < n; i++) {
            y[i] = nextInt();
        }
        s = new int[50];
        k = 0;
        for (int i = 0; i < n; i++) {
            if (x[i] > 0 && !canMake(x[i])) {
                s[k++] = i;
            }
        }
        for (int i = 0; i < n; i++) {
            if (!canMake(y[i])) {
                out.println(-1);
                return;
            }
        }
        for (int i = 0; i < n; i++) {
            boolean ok = true;
            for (int j = 0; j < k; j++) {
                if (s[j] == i) ok = false;
            }
            if (ok) {
                move(i, i);
                canMake(y[i]);
                for (int j = 0; j < k; j++) {
                    if (bit(zzz, j)) {
                        move(i, s[j]);
                    }
                }
            }
        }
        int[] a = new int[k];
        for (int i = 0; i < k; i++) {
            canMake(y[s[i]]);
            a[i] = zzz;
        }
//        for (int i = 0; i < k; i++) {
//            for (int i = 0; i )
//        }
        int c1 = mn;
        for (int i = 0; i < k; i++) {
            for (int t = i; t < k; t++) {
                if (bit(a[t], i)) {
                    if (t != i) {
                        move(s[i], s[t]);
                        a[i] ^= a[t];
                    }
                    for (int j = 0; j < k; j++) {
                        if (i != j && bit(a[j], i)) {
                            move(s[j], s[i]);
                            a[j] ^= a[i];
                        }
                    }
                    break;
                }
            }
        }
        int c2 = mn;
        for (int i = 0; i < k; i++) {
            if (!bit(a[i], i)) {
                for (int j = 0; j < k; j++) {
                    if (bit(a[j], i)) {
                        move(s[j], s[i]);
                    }
                }
                move(s[i], s[i]);
            }
        }
//
//        for (int i = 0; i < mn; i++) {
//            x[moves[0][i]] ^= x[moves[1][i]];
//        }
//        for (int i = 0; i < n; i++) {
//            if (x[i] != y[i]){
//                System.out.println(Arrays.toString(x) + " " + Arrays.toString(y));
//                break;
//            }
//        }
//        System.out.println(ll);
        out.println(mn);
        for (int i = 0; i < c1; i++) {
            out.println((moves[0][i] + 1) + " " + (moves[1][i] + 1));
            x[moves[0][i]] ^= x[moves[1][i]];
        }
//        out.println();
        for (int i = c2; i < mn; i++) {
            out.println((moves[0][i] + 1) + " " + (moves[1][i] + 1));
            x[moves[0][i]] ^= x[moves[1][i]];
        }
//        out.println();
        for (int i = c2 - 1; i >= c1; i--) {
            out.println((moves[0][i] + 1) + " " + (moves[1][i] + 1));
            x[moves[0][i]] ^= x[moves[1][i]];
        }
        for (int i = 0; i < n; i++) {
            if (x[i] != y[i]) {
                throw new RuntimeException();
            }
        }
    }

    int[][] moves = new int[2][1000000];
    int mn;

    private void move(int i, int j) {
        moves[0][mn] = i;
        moves[1][mn] = j;
        mn++;
    }

    private boolean canMake(int z) {
        int[] q = new int[k + 1];
        int[] w = new int[k + 1];
        for (int i = 0; i < k; i++) {
            q[i] = x[s[i]];
            w[i] = (1 << i);
        }
        q[k] = z;
        for (int j = 0; j < 31; j++) {
            int t = 0;
            while (t < k && !bit(q[t], j)) t++;
            if (t < k) {
                for (int i = 0; i <= k; i++) {
                    if (i != t && bit(q[i], j)) {
                        q[i] ^= q[t];
                        w[i] ^= w[t];
                    }
                }
            }
        }
        zzz = w[k];
        return q[k] == 0;
    }

    private boolean bit(int i, int j) {
        return ((i >> j) & 1) == 1;
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public static void main(String[] args) throws IOException {
        new F().run();
    }

    private void run() throws IOException {
        solve();
        out.close();
    }

}


import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collection;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskF solver = new TaskF();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskF {
    private static final int BIT = 30;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] source = new int[n];
        int[] target = new int[n];
        for (int i = 0; i < n; ++i)
            source[i] = in.nextInt();
        for (int i = 0; i < n; ++i)
            target[i] = in.nextInt();
        List<int[]> moveFromSource = gauss(source);
        List<int[]> moveFromTarget = gauss(target);
        List<int[]> moves = new ArrayList<>();
        moves.addAll(moveFromSource);
        for (int i = 0; i < n; ++i) {
            int last = i;
            for (int bit = 0; bit < BIT; ++bit)
                if ((source[i] & 1 << bit) != (target[i] & 1 << bit)) {
                    while (last < n && Integer.numberOfTrailingZeros(source[last]) < bit)
                        ++last;
                    if (last < n && Integer.numberOfTrailingZeros(source[last]) == bit) {
                        source[i] ^= source[last];
                        moves.add(new int[]{i, last});
                    } else {
                        out.println(-1);
                        return;
                    }
                    ++last;
                }
        }
        Collections.reverse(moveFromTarget);
        moves.addAll(moveFromTarget);
        out.println(moves.size());
        for (int[] move : moves) {
            out.print(move[0] + 1);
            out.print(' ');
            out.println(move[1] + 1);
        }
    }

    private List<int[]> gauss(int[] a) {
        int n = a.length;
        List<int[]> moves = new ArrayList<>();
        for (int bit = 0, last = 0; bit < BIT; ++bit) {
            boolean found = false;
            for (int x = last; x < n; ++x)
                if ((a[x] & 1 << bit) != 0) {
                    if (x != last) {
                        a[x] ^= a[last];
                        a[last] ^= a[x];
                        a[x] ^= a[last];
                        moves.add(new int[]{x, last});
                        moves.add(new int[]{last, x});
                        moves.add(new int[]{x, last});
                    }
                    found = true;
                    break;
                }
            if (!found) continue;
            for (int x = last + 1; x < n; ++x)
                if ((a[x] & 1 << bit) != 0) {
                    a[x] ^= a[last];
                    moves.add(new int[]{x, last});
                }
            ++last;
        }
        return moves;
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

}


import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collection;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskF solver = new TaskF();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskF {
    private static final int BIT = 30;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] source = new int[n];
        int[] target = new int[n];
        for (int i = 0; i < n; ++i)
            source[i] = in.nextInt();
        for (int i = 0; i < n; ++i)
            target[i] = in.nextInt();
        int[] importantBitOfSource = new int[BIT];
        int[] importantBitOfTarget = new int[BIT];
        List<int[]> moveFromSource = new ArrayList<>();
        List<int[]> moveFromTarget = new ArrayList<>();
        gauss(source, importantBitOfSource, moveFromSource);
        gauss(target, importantBitOfTarget, moveFromTarget);
        List<int[]> moves = new ArrayList<>();
        moves.addAll(moveFromSource);
        for (int i = 0; i < n; ++i) {
            int last = i;
            for (int bit = 0; bit < BIT; ++bit)
                if ((source[i] & 1 << bit) != (target[i] & 1 << bit)) {
                    while (last < n && Integer.numberOfTrailingZeros(source[last]) < bit)
                        ++last;
                    if (last < n && Integer.numberOfTrailingZeros(source[last]) == bit) {
                        source[i] ^= source[last];
                        moves.add(new int[]{i, last});
                    } else {
                        out.println(-1);
                        return;
                    }
                    ++last;
                }
        }
        Collections.reverse(moveFromTarget);
        moves.addAll(moveFromTarget);
        out.println(moves.size());
        for (int[] move : moves) {
            out.print(move[0] + 1);
            out.print(' ');
            out.println(move[1] + 1);
        }
    }

    private void gauss(int[] a, int[] importantBit, List<int[]> move) {
        int n = a.length;
        Arrays.fill(importantBit, -1);
        for (int bit = 0, last = 0; bit < BIT; ++bit) {
            boolean found = false;
            for (int x = last; x < n; ++x)
                if ((a[x] & 1 << bit) != 0) {
                    if (x != last) {
                        a[x] ^= a[last];
                        a[last] ^= a[x];
                        a[x] ^= a[last];
                        move.add(new int[]{x, last});
                        move.add(new int[]{last, x});
                        move.add(new int[]{x, last});
                    }
                    found = true;
                    break;
                }
            if (!found) continue;
            importantBit[bit] = last;
            for (int x = last + 1; x < n; ++x)
                if ((a[x] & 1 << bit) != 0) {
                    a[x] ^= a[last];
                    move.add(new int[]{x, last});
                }
            ++last;
        }
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

}