#define DEBUG 0
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
template < template < typename ... > class Container, typename Value >
auto make_z_array(Container< Value > const & s) -> std::vector< int > {
  if (s.empty()) return {};
  auto n = (int)s.size();
  std::vector< int > ret(n);
  ret.at(0) = n;
  auto i = 1, j = 0;
  while (i < n) {
    while (i + j < n && s.at(j) == s.at(i + j))
      { j++; }
    ret.at(i) = j;
    if (j == 0)
      { i++; }
    else {
      auto k = 1;
      while (i + k < n && k + ret.at(k) < j) {
        ret.at(i + k) = ret.at(k);
        k++;
      }
      i += k, j -= k;
    }
  }
  return ret;
}

// Returns turns all the occurence of w in s.
template < template < typename ... > class Container, typename Value >
auto z_search(Container< Value > const & w, Container< Value > const & s, Value dammy) -> std::vector<int> {
  debug(w,s,dammy);
  if (s.empty()) return {};
  assert(!w.empty());
  assert(std::find(w.begin(), w.end(), dammy) == w.end());
  assert(std::find(s.begin(), s.end(), dammy) == s.end());
  auto long_string = w;
  long_string.push_back(dammy);
  long_string.insert(long_string.end(), s.begin(), s.end());
  auto z_array = make_z_array(std::move(long_string));
  int m = w.size(), n = s.size();
  std::vector<int> ret;
  for (int i = 0; i < n; i++) {
    if (z_array.at(m + 1 + i) == m)
      { ret.push_back(i); }
  }
  return ret;
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n), b(n), A(n), B(n);
  std::cin>>a>>b;
  rep(i,0,n) {
    A.at(i) = a.at(i) ^ a.at(0 < i ? i - 1 : n - 1);
    B.at(i) = b.at(i) ^ b.at(0 < i ? i - 1 : n - 1);
  }
  debug(a,A,b,B);

  rep(i,0,n) {
    A.emplace_back(A.at(i));
  }

  auto occur = z_search(B, A, -1);
  debug(occur);
  for (int k : occur) {
    if (n <= k) continue;
    int x = a.at(k) ^ b.at(0);
    std::cout << k << " " << x << std::endl;
  }
  return 0;
}

/*
(K, X) が答えになる条件は、
a, b それぞれ隣接 xor をとっておいて回転になっていることです。
これは、KMP などで判定できます。
*/

Measured memory_bytes: 10720