Example

Input

3
()(()((
))()()(()
)())(())


Output

Yes
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N;
l_l a[105];

l_l f(string s) {
    ll delta = 0;
    ll minimum = 0;
    for(auto c : s) {
        if(c == '(') delta++;
        else delta--;
        chmin(minimum, delta);
    }
    return {delta, minimum};
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    vector<l_l> one, two;
    for(int i = 0; i < N; i++) {
        string s;
        cin >> s;
        l_l now = f(s);
        if(now.first >= 0) {
            one.push_back({-now.second, now.first});
        } else {
            two.push_back({now.second - now.first, now.first});
        }
    }
    sort(one.begin(), one.end());
    sort(two.begin(), two.end());
    ll now = 0;
    bool ok = true;
    for(auto tmp : one) {
        //cerr << -tmp.first << " " << tmp.second << endl;
        if(now < tmp.first) ok = false;
        now += tmp.second;
    }
    for(auto tmp : two) {
        //cerr << tmp.first << " " << tmp.second << endl;
        if(now < -tmp.first - tmp.second) ok = false;
        now += tmp.second;
    }
    if(now != 0) ok = false;
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}
