Example

Input

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


Output

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

struct edge{
  int s,t;
};

int N,sum=0;
string str;
vector<int> a[100];
vector<edge> A,B;

bool solve( vector<edge> &A ){
  int pos=0;
  vector<bool> used(A.size());
  for(int i=0;i<(int)A.size();i++){
    int id=-1;
    for(int j=0;j<(int)A.size();j++){
      if(used[j])continue;
      if(A[j].s<=pos){
        id=j;
        used[j]=true;
        pos+=A[j].t;
        break;
      }
    }
    if(id==-1)return false;
  }
  return true;
}

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>str;
    a[i].resize( str.size() + 1 );
    a[i][0]=0;
    int mini=0;
    for(int j=1;j<(int)a[i].size();j++){
      a[i][j]=a[i][j-1];
      if(str[j-1]=='(')a[i][j]++;
      else a[i][j]--;
      mini=min(mini,a[i][j]);
    }
    sum+=a[i].back();
    if(a[i].back()>0){
      A.push_back((edge){-mini,a[i].back()});
    }else{
      B.push_back((edge){-mini+a[i].back(),-a[i].back()});
    }
  }
  if(sum!=0){
    cout<<"No"<<endl;
    return 0;
  }
  if( solve(A) && solve(B) ){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}