Problem: There are some tasks which have the following structure: you are given a model, and you can do some operations, you should use these operations to achive the goal. One way to create a new task is to use the same model and same operations, but change the goal.

Let's have a try. I have created the following task for Topcoder SRM 557 Div1-Hard: you are given n integers x1, x2, ..., xn. You are allowed to perform the assignments (as many as you want) of the following form xi ^= xj (in the original task i and j must be different, but in this task we allow i to equal j). The goal is to maximize the sum of all xi.

Now we just change the goal. You are also given n integers y1, y2, ..., yn. You should make x1, x2, ..., xn exactly equal to y1, y2, ..., yn. In other words, for each i number xi should be equal to yi.

Input

The first line contains an integer n (1 ≤ n ≤ 10000). The second line contains n integers: x1 to xn (0 ≤ xi ≤ 109). The third line contains n integers: y1 to yn (0 ≤ yi ≤ 109).

Output

If there is no solution, output -1.

If there is a solution, then in the first line output an integer m (0 ≤ m ≤ 1000000) – the number of assignments you need to perform. Then print m lines, each line should contain two integers i and j (1 ≤ i, j ≤ n), which denote assignment xi ^= xj.

If there are multiple solutions you can print any of them. We can prove that under these constraints if there exists a solution then there always exists a solution with no more than 106 operations.

Examples

Input

2
3 5
6 0


Output

2
1 2
2 2


Input

5
0 0 0 0 0
1 2 3 4 5


Output

-1


Input

3
4 5 6
1 2 3


Output

5
3 1
1 2
2 2
2 3
3 1


Input

3
1 2 3
4 5 6


Output

-1

Note

Assignment a ^= b denotes assignment a = a ^ b, where operation "^" is bitwise XOR of two integers.

Solution (in JAVA):

Solution:
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
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 {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();
        }
        int[] B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = in.nextInt();
        }

        ArrayList<Integer> aMoves = new ArrayList<Integer>();
        int[] aBase = gauss(A, aMoves);

        ArrayList<Integer> bMoves = new ArrayList<Integer>();
        int[] bBase = gauss(B, bMoves);

        ArrayList<Integer> changeMoves = new ArrayList<Integer>();
        int[] aux = new int[N];
        boolean ok = true;
        for (int i = 0; i < N && ok; i++) {
            int p = 0;
            int b = bBase[i];
            int a = 0;
            for (int j = i; j < N && aBase[j] != 0 && a != b; ) {
                int bit = Integer.bitCount(Integer.lowestOneBit(aBase[j]) - 1);
                if ((b & (1 << bit)) != (a & (1 << bit))) {
                    a ^= aBase[j];
                    aux[p++] = j;
                }
                else {
                    j++;
                }
            }

            if (a == b) {
                if (p > 0) {
                    if (aux[0] != i) {
                        addSwapMoves(aux[0], i, changeMoves);
                        int ax = aBase[0];
                        aBase[0] = aBase[aux[0]];
                        aBase[aux[0]] = ax;
                    }
                    for (int j = 1; j < p; j++) {
                        changeMoves.add(i); changeMoves.add(aux[j]);
                    }
                }
                else {
                    changeMoves.add(i); changeMoves.add(i);
                }
            }
            else {
                ok = false;
            }
        }

        if (!ok) {
            out.println(-1);
        }
        else {
            int totalMoves = (aMoves.size() + bMoves.size() + changeMoves.size()) / 2;
            out.println(totalMoves);
            for (int i = 0; i < aMoves.size(); i += 2) {
                out.println((aMoves.get(i) + 1) + " " + (aMoves.get(i + 1) + 1));
            }
            for (int i = 0; i < changeMoves.size(); i += 2) {
                out.println((changeMoves.get(i) + 1) + " " + (changeMoves.get(i + 1) + 1));
            }
            for (int i = bMoves.size() - 2; i >= 0; i -= 2) {
                out.println((bMoves.get(i) + 1) + " " + (bMoves.get(i + 1) + 1));
            }
        }
    }

    private int[] gauss(int[] A, ArrayList<Integer> moves) {
        int N = A.length;
        int[] base = new int[N];
        System.arraycopy(A, 0, base, 0, N);
        int k = 0;
        for (int j = 0; j < 30; j++) {
            int i = k;
            while (i < N && (base[i] & (1 << j)) == 0) {
                i++;
            }
            if (i == N) {
                continue;
            }

            if (i != k) {
                int aux = base[i];
                base[i] = base[k];
                base[k] = aux;
                addSwapMoves(i, k, moves);
            }

            for (int p = k + 1; p < N; p++) {
                if ((base[p] & (1 << j)) > 0) {
                    base[p] ^= base[k];
                    moves.add(p);
                    moves.add(k);
                }
            }

            k++;
        }

        return base;
    }

    private void addSwapMoves(int a, int b, ArrayList<Integer> moves) {
        moves.add(a); moves.add(b);
        moves.add(b); moves.add(a);
        moves.add(a); moves.add(b);
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

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

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));

        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

}