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;

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