#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

template<int mod>
struct mint{
  int x;
  mint() : x(0) {}
  mint(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  mint &operator+=(const mint &p) { if((x += p.x) >= mod) x -= mod; return *this; }
  mint &operator-=(const mint &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; }
  mint &operator*=(const mint &p) { x = (int) (1LL * x * p.x % mod); return *this; }
  mint &operator/=(const mint &p) { *this *= p.inverse(); return *this; }
  mint &operator^=(ll n) {
    int y = x; x = 1;
    while(n > 0) {
      if(n & 1) x = 1LL * x * y % mod; y = 1LL * y * y % mod; n /= 2; }
    return *this; }
  mint operator-() const { return mint(-x); }
  mint operator+(const mint &p) const { return mint(*this) += p; }
  mint operator-(const mint &p) const { return mint(*this) -= p; }
  mint operator*(const mint &p) const { return mint(*this) *= p; }
  mint operator/(const mint &p) const { return mint(*this) /= p; }
  mint operator^(const ll n) const { return mint(*this) ^= n; }
  bool operator==(const mint &p) const { return x == p.x; }
  bool operator!=(const mint &p) const { return x != p.x; }
  mint inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
    return mint(u); }
  friend ostream &operator<<(ostream &os, const mint<mod> &p) { return os << p.x; }
  friend istream &operator>>(istream &is, mint< mod > &a) { 
	  ll t; is >> t; a = mint<mod>(t); return (is); }
};

struct rhash { //don't forget to base_init()!!!!!
	mint<1000000007> v1;
	mint<1000000009> v2;
	rhash() : v1(0), v2(0) {}
	rhash(ll a) : v1(a), v2(a) {}
	rhash(ll a, ll b) : v1(a), v2(b) {}
	rhash &operator+=(const rhash &hs) { v1 += hs.v1; v2 += hs.v2; return *this; }
	rhash &operator-=(const rhash &hs) { v1 -= hs.v1; v2 -= hs.v2; return *this; }
	rhash &operator*=(const rhash &hs) { v1 *= hs.v1; v2 *= hs.v2; return *this; }
	rhash &operator/=(const rhash &hs) { v1 /= hs.v1; v2 /= hs.v2; return *this; }
	rhash &operator^=(ll n) { v1 ^= n; v2 ^= n; return *this; }
	rhash operator-() const { rhash hs; hs.v1 = -v1; hs.v2 = -v2; return hs; }
	rhash operator+(const rhash& hs) const { return rhash(*this) += hs; }
	rhash operator-(const rhash& hs) const { return rhash(*this) -= hs; }
	rhash operator*(const rhash& hs) const { return rhash(*this) *= hs; }
	rhash operator/(const rhash& hs) const { return rhash(*this) /= hs; }
	rhash operator^(ll n) const { return rhash(*this) ^= n; }
	bool operator<(const rhash &hs) const { return pi(v1.x, v2.x) < pi(hs.v1.x, hs.v2.x); }
	bool operator==(const rhash& hs) { return v1 == hs.v1 && v2 == hs.v2; }
	bool operator!=(const rhash& hs) { return v1 != hs.v1 || v2 != hs.v2; }
	friend ostream &operator<<(ostream &os, const rhash &hs) { return os << pi(hs.v1.x, hs.v2.x); }
};

rhash base;

void base_init() {
	int v1 = uniform_int_distribution<int>(0, 1000000007 - 1)(rng);
	int v2 = uniform_int_distribution<int>(0, 1000000009 - 1)(rng);
	base = rhash(v1, v2);
}


int N;
int A[MAX_N], B[MAX_N];
int C[MAX_N], D[MAX_N];

void solve() {
	cin >> N;
	base_init();
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N) cin >> B[i];
	rhash ah = 0, bh = 0;
	rhash tmp = 1;
	rep(i, 0, N) {
		C[i] = A[(i + 1) % N] ^ A[i];
		D[i] = B[(i + 1) % N] ^ B[i];
		ah += rhash(C[i]) * tmp;
		bh += rhash(D[i]) * tmp;
		tmp *= base;
	}
	// debug(vi(C, C + N));
	// debug(vi(D, D + N));
	tmp /= base;
	rep(i, 0, N) {
		if(bh == ah) {
			cout << i << " " << (A[0] ^ B[(N - i) % N]) << "\n";
		}
		ah -= rhash(C[i]);
		ah /= base;
		ah += rhash(C[i]) * tmp;
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 8960