using System;
using System.Collections.Generic;
using System.Text;
using CompLib.Util;

public class Program
{
    private int N;
    private int[] A, B;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();
        B = sc.IntArray();

        // aの隣接する2数のxor
        var aa = new int[2 * N + 1];
        for (int i = 0; i < N; i++)
        {
            aa[i] = A[i] ^ A[(i + 1) % N];
            if (i < N - 1) aa[i + N] = aa[i];
        }

        // b
        var bb = new int[N];
        for (int i = 0; i < N; i++)
        {
            bb[i] = B[i] ^ B[(i + 1) % N];
        }

        var l = KMP(aa, bb);
        var sb = new StringBuilder();
        foreach (int i in l)
        {
            sb.AppendLine($"{i} {B[0] ^ A[i]}");
        }

        Console.Write(sb.ToString());
    }

    private int[] KMP(int[] a, int[] b)
    {
        int[] table = CreateTable(b);
        List<int> l = new List<int>();
        int i = 0, p = 0;
        while (i < 2 * N - 1)
        {
            if (p == N)
            {
                l.Add(i - N);
                p = table[p];
            }
            else if (a[i] == b[p])
            {
                i++;
                p++;
            }
            else if (p == 0)
            {
                i++;
            }
            else
            {
                p = table[p];
            }
        }

        if (p == N)
        {
            l.Add(i - N);
            // p = table[p];
        }

        return l.ToArray();
    }

    private int[] CreateTable(int[] a)
    {
        int[] table = new int[N + 1];
        table[0] = 0;
        int j = 0;
        for (int i = 1; i < N; i++)
        {
            if (a[i] == a[j]) table[i] = j++;
            else
            {
                table[i] = j;
                j = 0;
            }
        }

        table[N] = j;
        return table;
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 55820