Example

Input

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


Output

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

int N;

struct state{
  int pl,c1,c2,id;
  bool r;
  state(int c1,int c2,int id,bool r):c1(c1),c2(c2),id(id),r(r) {
    if( c2 >= 0 ) pl = -1;
    else pl = 0;
  }
  bool operator<(const state& st) const {
    if( pl == st.pl ){
      if( pl == -1 )
        return c1 < st.c1;
      else
        return c1+c2 > st.c1+st.c2;
    } else
      return pl < st.pl;    
  }
};

vector<state> S;

void counter(const string& s,int &c1,int &c2){//c1???????????????,c2?????????
  c1=0; c2=0;  
  for(int i=0;i<(int)s.size();i++){
    if( s[i] == '(' ) c2++;
    else c2--;
    c1 = min(c1,c2);
  }
  c1*=-1;
}

bool solve(){
  int Ls=0,Rs=0;
  bool used[111]={};
  sort(S.begin(),S.end());
  for(int i=0;i<(int)S.size();i++){
    if( used[S[i].id] ) continue;
    if( S[i].r ) { //rev[R]
      if( Rs<S[i].c1 ) return false;
      Rs+=S[i].c2;
    } else { //[L]
      if( Ls<S[i].c1 ) return false;
      Ls+=S[i].c2;
    }
    used[S[i].id]=true;
  }
  
  return Ls==Rs;
}

void reverse_s(string& s){
  reverse(s.begin(),s.end());
  for(int i=0;i<(int)s.size();i++)
    if( s[i] == '(' ) s[i] = ')';
    else s[i] = '(';  
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    string s; cin >> s;
    int c1,c2; counter(s,c1,c2);
    S.push_back( state( c1, c2, i, false ) );
    reverse_s(s); counter(s,c1,c2);
    S.push_back( state( c1, c2, i, true ) );
  }
  cout << ( solve()?"Yes":"No" ) << endl;
}