Example

Input

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


Output

Yes
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main(void) {
  ll N;
  cin >> N;
  vector<string> S(N);
  REP(i, 0, N) cin >> S[i];

  vector<pll> left, right;
  REP(i, 0, N) {
    ll bottom = 0, level = 0;
    REP(j, 0, S[i].size()) {
      if(S[i][j] == '(') level++;
      if(S[i][j] == ')') level--;
      bottom = min(bottom, level);
    }
    if(level >= 0) left.push_back(pll(level, bottom));
    else {
      ll bottom = 0, level = 0;
      for(ll j = S[i].size() - 1; j >= 0; j--) {
        if(S[i][j] == ')') level++;
        if(S[i][j] == '(') level--;
        bottom = min(bottom, level);
      }
      right.push_back(pll(level, bottom));
    }
  }

  ll lh = 0, rh = 0;
  vector<bool> lused(left.size(), false), rused(right.size(), false);

  ll sum = 0;
  REP(i, 0, left.size()) sum += left[i].first;
  REP(i, 0, right.size()) sum -= right[i].first;
  if(sum != 0) goto NO;

  REP(i, 0, left.size()) {
    ll t = -1;
    REP(j, 0, left.size()) if(!lused[j] && lh + left[j].second >= 0) t = j;
    if(t == -1) goto NO;
    lh += left[t].first;
    lused[t] = true;
  }

  REP(i, 0, right.size()) {
    ll t = -1;
    REP(j, 0, right.size()) if(!rused[j] && rh + right[j].second >= 0) t = j;
    if(t == -1) goto NO;
    rh += right[t].first;
    rused[t] = true;
  }

  cout << "Yes" << endl;
  return 0;
NO:
  cout << "No" << endl;
}

