Example

Input

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


Output

Yes
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  string s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  int op[n],cl[n];
  int op2[n],cl2[n];
  memset(op,0,sizeof(op));
  memset(cl,0,sizeof(cl));
  memset(op2,0,sizeof(op2));
  memset(cl2,0,sizeof(cl2));
  for(int i=0;i<n;i++){
    for(int j=0;j<(int)s[i].size();j++){
      if(s[i][j]=='(') op[i]++;
      else op[i]--;
      cl[i]=min(cl[i],op[i]);
    }
    for(int j=(int)s[i].size()-1;j>=0;j--){
      if(s[i][j]==')') op2[i]++;
      else op2[i]--;
      cl2[i]=min(cl2[i],op2[i]);
    }
  }
  int tmp=0;
  bool f=1;
  bool used[n];
  memset(used,0,sizeof(used));
  while(1){
    int idx=-1;
    for(int i=0;i<n;i++){
      if(used[i]) continue;
      if(tmp+cl[i]<0) continue;
      if(idx<0||op[idx]<op[i]) idx=i;
    }
    if(idx<0||op[idx]<0) break;
    tmp+=op[idx];
    used[idx]=1;
  }
  int tmp2=0;
  while(1){
    int idx=-1;
    for(int i=0;i<n;i++){
      if(used[i]) continue;
      if(tmp2+cl2[i]<0) continue;
      if(idx<0||op2[idx]<op2[i]) idx=i;
    }
    if(idx<0||op2[idx]<0) break;
    tmp2+=op2[idx];
    used[idx]=1;
  }
  //cout<<tmp<<" "<<tmp2<<endl;
  f&=tmp==tmp2;
  for(int i=0;i<n;i++) f&=used[i];
  //for(int i=0;i<n;i++) cout<<used[i];cout<<endl;
  //for(int i=0;i<n;i++) if(!used[i]) cout<<i<<":"<<s[i]<<" "<<op[i]<<" "<<cl[i]<<endl;
  cout<<(f?"Yes":"No")<<endl;
  return 0;
}