#include <iostream>
#include <algorithm>
#include <vector>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 9;
using mint = ModInt<MOD>;

std::vector<mint> twopow;

struct Bin {
    std::vector<mint> acc;

    explicit Bin(const std::vector<int>& xs) {
        int n = xs.size();
        acc.resize(n + 1);
        acc[n] = 0;
        for (int i = n - 1; i >= 0; --i) {
            acc[i] = acc[i + 1] * 2 + xs[i];
        }
    }

    mint seg(int l, int r) {
        return acc[l] - acc[r] * twopow[r - l];
    }
};

int main() {
    twopow.resize(300000);
    twopow[0] = 1;
    for (int i = 1; i < 300000; ++i) {
        twopow[i] = twopow[i - 1] * 2;
    }

    int n;
    std::cin >> n;

    std::vector<std::vector<int>>
        xbs(30, std::vector<int>(n)),
        ybs(30, std::vector<int>(n));

    for (int i = 0; i < n; ++i) {
        int x;
        std::cin >> x;
        for (int k = 0; k < 30; ++k) {
            xbs[k][i] = ((x >> k) & 1);
        }
    }

    for (int i = 0; i < n; ++i) {
        int y;
        std::cin >> y;
        for (int k = 0; k < 30; ++k) {
            ybs[k][i] = ((y >> k) & 1);
        }
    }

    std::vector<std::vector<int>>
        ans(30, std::vector<int>(n, -1));

    for (int k = 0; k < 30; ++k) {
        for (int q = 0; q < 2; ++q) {
            Bin xbin(xbs[k]), ybin(ybs[k]);
            auto yseg = ybin.seg(0, n);

            for (int s = 0; s < n; ++s) {
                mint val = xbin.seg(0, s) * twopow[n - s] + xbin.seg(s, n);
                if (val == yseg) ans[k][s] = q;
            }

            for (auto& xb : xbs[k]) xb = 1 - xb;
        }
    }

    std::vector<std::pair<int, int>> ps;
    for (int s = 0; s < n; ++s) {
        int x = 0;
        bool ok = true;

        for (int k = 0; k < 30; ++k) {
            if (ans[k][s] < 0) {
                ok = false;
            } else {
                x |= (ans[k][s] << k);
            }
        }

        if (ok) ps.emplace_back(s, x);
    }

    std::sort(ps.begin(), ps.end());
    for (auto p : ps) {
        std::cout << p.first << " " << p.second << std::endl;
    }
    return 0;
}


Measured memory_bytes: 78188