#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=2e5+10;

const ll base=1e9+7;
const ll mod=2038077799;

ll ha,hb,a[maxn],b[maxn],difa[maxn],difb[maxn];
int n; 

ll getval(ll x,ll k,ll mod){
	if(k==0) return 1ll;
	if(k==1) return x;
	ll res=getval(x,k/2,mod);
	res=(res*res)%mod;
	if(k&1) res=(res*x)%mod;
	return res;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	for(int i=0;i<n;i++) scanf("%lld",&b[i]);
	for(int i=0;i<n;i++) difa[i]=a[i]^a[(i+1)%n];
	for(int i=0;i<n;i++) difb[i]=b[i]^b[(i+1)%n];
	ha=hb=0;
	for(int i=0;i<n;i++){
		ha*=base; ha%=mod;
		ha+=difa[i]; ha%=mod;
	}
	for(int i=0;i<n;i++){
		hb*=base; hb%=mod;
		hb+=difb[i]; hb%=mod;
	}
	ll val=getval(base,n-1,mod);
	vector <int> ans;
	for(int i=0;i<n;i++){
		if(ha==hb){
			ans.pb(i);  
		}
		ll now=val*difa[i]; now%=mod;
		ha+=mod-now; ha%=mod;
		ha*=base; ha%=mod;
		ha+=difa[i]; ha%=mod; 
	}
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<" "<<(a[0]^b[(n-ans[i])%n])<<endl;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

struct Stat {
    int unmatchedOpening, unmatchedClosing, index;
    Stat(int _uo, int _uc, int _index): unmatchedOpening(_uo), unmatchedClosing(_uc), index(_index) {}
};

//Comparing two stats which unmatchedOpening - unmatchedClosing >= 0
bool cmpFirst(Stat a, Stat b) {
    return a.unmatchedClosing < b.unmatchedClosing;
}

//Comparing two stats which unmatchedOpening - unmatchedClosing < 0
bool cmpSecond(Stat a, Stat b) {
    return a.unmatchedOpening > b.unmatchedOpening;
}

//{unmatchedOpening, unmatchedClosing}
pair<int, int> getStat(string s) {
    int unmatchedOpening = 0;
    int unmatchedClosing = 0;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '(') {
            unmatchedOpening += 1;
        } else {
            if (unmatchedOpening > 0)
                unmatchedOpening -= 1;
            else
                unmatchedClosing += 1;
        }
    }

    return make_pair(unmatchedOpening, unmatchedClosing);
}

int main() {
    int n;
    vector<Stat> first; //unmatchedOpening - unmatchedClosing >= 0
    vector<Stat> second; //unmatchedOpening - unmatchedClosing < 0

    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;

        auto stat = getStat(s);
        if (stat.first - stat.second >= 0)
            first.push_back(Stat(stat.first, stat.second, i));
        else
            second.push_back(Stat(stat.first, stat.second, i));
    }

    sort(first.begin(), first.end(), cmpFirst);
    sort(second.begin(), second.end(), cmpSecond);

    bool valid = true;
    int balance = 0;

    for (auto f: first) {
        if (balance - f.unmatchedClosing < 0) {
            valid = false;
            break;
        }

        balance -= f.unmatchedClosing;
        balance += f.unmatchedOpening;
    }

    for (auto s: second) {
        if (balance - s.unmatchedClosing < 0) {
            valid = false;
            break;
        }

        balance -= s.unmatchedClosing;
        balance += s.unmatchedOpening;
    }

    if (balance != 0)
        valid = false;

    if (valid) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

/*
Test cases:

4
(
))(((
)((
)))
*/
