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.*;
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() );
        }
    }
}