using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC150F
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            int[] a = ReadInt();
            int[] b = ReadInt();

            //差分列の作成
            int[] adiv = new int[N];
            int[] bdiv = new int[N];
            for (int i = 0; i < N; i++)
            {
                adiv[i] = a[(i + 1) % N] ^ a[i];
                bdiv[i] = b[(i + 1) % N] ^ b[i];
            }

            //長くする
            int[] along = new int[2 * N];
            Array.Copy(adiv, along, N);
            Array.Copy(adiv, 0, along, N, N);

            //dをずらしてマッチする部分を探す。
            List<int> k = new List<int>();
            List<int> x = new List<int>();
            RollingHash rh1 = new RollingHash(along);
            RollingHash rh2 = new RollingHash(bdiv);
            var hash = rh2.Hash();
            for (int i = 0; i < N; i++)
            {
                bool ok = false;

                //これだと遅いはず。
                //for (int w = 0; w < N; w++)
                //{
                //    if (along[i + w] != bdiv[w]) ok = false;
                //}
                var hash1 = rh1.Get(i, i + N);
                if (hash[0] == hash1[0] && hash[1] == hash1[1]) ok = true;

                if (ok)
                {
                    k.Add(i);
                    x.Add(a[i] ^ b[0]);
                }
            }

            //出力
            if (k.Count > 0)
            {
                for (int i = 0; i < k.Count; i++)
                {
                    Console.WriteLine(k[i] + " " + x[i]);
                }
            }
            else Console.WriteLine();
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }

    /// <summary>
    /// ローリングハッシュ安全バージョン
    /// </summary>
    class RollingHash
    {
        const long base1 = 1009;
        const long base2 = 2009;
        const long mod1 = 1000000007;
        const long mod2 = 1000000009;
        long[] hash1, hash2, pow1, pow2;

        public RollingHash(int[] S)
        {
            int n = S.Length;
            hash1 = new long[n + 1];
            hash2 = new long[n + 1];
            pow1 = new long[n + 1];
            pow2 = new long[n + 1];
            pow1[0] = 1;
            pow2[0] = 1;

            for (int i = 0; i < n; ++i)
            {
                hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
                hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
                pow1[i + 1] = (pow1[i] * base1) % mod1;
                pow2[i + 1] = (pow2[i] * base2) % mod2;
            }
        }

        /**
         * S の [l, r) のハッシュ値を返す
         * O(1)
         */
        public long[] Get(int l, int r)
        {
            long res1 = hash1[r] - hash1[l] * pow1[r - l] % mod1;
            if (res1 < 0) res1 += mod1;
            long res2 = hash2[r] - hash2[l] * pow2[r - l] % mod2;
            if (res2 < 0) res2 += mod2;
            return new long[] { res1, res2 };
        }

        /**
         * S のハッシュ値を返す
         * O(1)
         */
        public long[] Hash()
        {
            return Get(0, hash1.Length - 1);
        }

        /**
         * LCP (Longest Common Prefix)
         * O( log N )
         */
        public int GetLCP(int a, int b)
        {
            int len = Math.Min(hash1.Length - a, hash1.Length - b);
            int low = 0, high = len;
            while (high - low > 1)
            {
                int mid = (low + high) >> 1;
                if (Get(a, a + mid) != Get(b, b + mid)) high = mid;
                else low = mid;
            }
            return low;
        }

        /**
         * hash h1 と 長さ h2_len の文字列の hash h2 を結合
         */
        public long[] Concat(long[] h1, long[] h2, int h2_len)
        {
            return new long[] { (h1[0] * pow1[h2_len] + h2[0]) % mod1, (h1[1] * pow2[h2_len] + h2[1]) % mod2 };
        }
    }
}


Measured memory_bytes: 52508