#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

// Morris-Pratt
// https://youtu.be/9MphwmIsO7Q?t=7283
template<typename T>
struct MP {
    int n;
    T t;
    vector<int> a;
    MP() {}
    MP(const T& t): t(t) {
        n = t.size();
        a = vector<int>(n+1);
        a[0] = -1;
        int j = -1;
        for (int i = 0; i < n; ++i) {
            while (j != -1 && t[j] != t[i]) j = a[j];
            j++;
            a[i+1] = j;
        }
    }
    int operator[](int i) { return a[i];}
    vector<int> findAll(const T& s) {
        vector<int> res;
        int j = 0;
        for (int i = 0; i < s.size(); ++i) {
            while (j != -1 && t[j] != s[i]) j = a[j];
            j++;
            if (j == n) {
                res.push_back(i-j+1);
                j = a[j];
            }
        }
        return res;
    }
};

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    
    vector<ll> ax(n);
    vector<ll> bx(n);
    rep(i, n) {
        ax[i] = a[i]^a[(i+1)%n];
        bx[i] = b[i]^b[(i+1)%n];
    }
    ax.insert(ax.end(), ax.begin(), ax.end());
    
    MP<vector<ll>> mp(bx);
    vector<int> match = mp.findAll(ax);
    for (int e:match) {
        if (e>=n) continue;
        ll x = a[e] ^ b[0];
        cout << e << " " << x << endl;
    }
    
    
   
    //cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

bool f(P l,P r){
    int a = l.second - l.first;
    int b = r.second - r.first;
    if(a > 0 && b <= 0){
        return true;
    }
    if(a <= 0 && b > 0){
        return false;
    }
    if(a > 0 && b > 0){
        return l.first < r.first;
    }if(a < 0 && b < 0){
        return l.second > r.second;
    }
}

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    vector<P> lr(n);
    rep(i,n){
        int l = 0;
        int r = 0;
        rep(j,s[i].size()){
            if(s[i][j] == '('){
                ++r;
            }else{
                if(r > 0) --r;
                else ++l;
            }
        }
        lr[i].first = l;
        lr[i].second = r;
    }

    sort(lr.begin(),lr.end(),f);
    if(lr[0].first!=0){
        cout << "No" << endl;
        return 0;
    }
    int l = 0;
    int r = 0;
    rep(i,n){
        if(r < lr[i].first){
            cout << "No" << endl;
            return 0;
        }
        r -= lr[i].first;
        r += lr[i].second;
    }
    cout << (r==0?"Yes":"No") << endl;
    return 0;
}
