Anton goes to school, his favorite lessons are arraystudying. He usually solves all the tasks pretty fast, but this time the teacher gave him a complicated one: given two arrays b and c of length n, find array a, such that:

<image>

where a and b means bitwise AND, while a or b means bitwise OR.

Usually Anton is good in arraystudying, but this problem is too hard, so Anton asks you to help.

Input

The first line of the input contains a single integers n (1 ≤ n ≤ 200 000) — the size of arrays b and c.

The second line contains n integers bi (0 ≤ bi ≤ 109) — elements of the array b.

Third line contains n integers ci (0 ≤ ci ≤ 109) — elements of the array c.

Output

If there is no solution, print  - 1.

Otherwise, the only line of the output should contain n non-negative integers ai — elements of the array a. If there are multiple possible solutions, you may print any of them.

Examples

Input

4
6 8 4 4
16 22 10 10


Output

3 5 1 1 


Input

5
8 25 14 7 16
19 6 9 4 25


Output

-1
import java.io.*;
import java.util.StringTokenizer;

public class F {

    void solve() throws IOException {
        FastScanner scanner = new FastScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        int n = scanner.nextInt();
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        }
        for (int i = 0; i < n; i++) {
            c[i] = scanner.nextInt();
        }
        int[] a = getA(b, c);
        int[] k = getK(a);
        long[][] bc = getBC(a, k);
        if (eq(b, bc[0]) && eq(c, bc[1])) {
            for (int i = 0; i < n; i++) {
                writer.print(a[i] + " ");
            }
        } else {
            writer.println(-1);
        }
        writer.close();
    }

    int[] getA(int[] b, int[] c) {
        int n = b.length;
        int[] a = new int[n];
        long s = 0;
        for (int i = 0; i < n; i++) {
            s += (long) b[i] + c[i];
        }
        for (int i = 0; i < n; i++) {
            a[i] = (int) ((b[i] + c[i] - s / 2 / n) / n);
        }
        return a;
    }

    long[][] getBC(int[] a, int[] k) {
        int n = a.length;
        int m = 1;
        long[] b = new long[n];
        long[] c = new long[n];
        for (int i = 0; i < k.length; i++) {
            for (int j = 0; j < n; j++) {
                if ((a[j] & m) != 0) {
                    b[j] += m * k[i];
                    c[j] += m * n;
                } else {
                    c[j] += m * k[i];
                }
            }
            m *= 2;
        }
        return new long[][]{b, c};
    }

    int[] getK(int[] x) {
        int max = x[0];
        for (int a : x) {
            max = Math.max(max, a);
        }
        int l = 0;
        int m = 1;
        while (m <= max) {
            m *= 2;
            l++;
        }
        int[] k = new int[l];
        m = 1;
        for (int i = 0; i < l; i++) {
            for (int a : x) {
                if ((a & m) != 0) {
                    k[i]++;
                }
            }
            m *= 2;
        }
        return k;
    }

    boolean eq(int[] x, long[] y) {
        for (int i = 0; i < x.length; i++) {
            if (x[i] != y[i]) {
                return false;
            }
        }
        return true;
    }

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

    static class FastScanner {

        BufferedReader br;
        StringTokenizer tokenizer;

        FastScanner(String fileName) throws FileNotFoundException {
            this(new FileInputStream(new File(fileName)));
        }

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String nextLine() throws IOException {
            tokenizer = null;
            return br.readLine();
        }

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

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

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