Example

Input

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


Output

Yes
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
#define MM(a,b) memset(a,b,sizeof(a));
const double eps = 1e-10;
const int  inf =0x7f7f7f7f;
const double pi=acos(-1);
const int maxn=40000;

struct node {
   int x,y;
   bool operator<(const node&a) const{
       return this->x<a.x;
   }
};
vector<node> A,B;
char s[10000];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        A.clear();B.clear();
        for(int i=1;i<=n;i++)
        {
            scanf("%s",s);
            int l=0,r=0;
            for(int j=0;s[j]!='\0';j++)
            {
                 if(s[j]=='(') r++;
                 else if(!r) l++;
                 else r--;
            }
            if(l>r) B.push_back((node){r,l-r});
            else  A.push_back((node){l,r-l});
        }

        sort(A.begin(),A.end());
        sort(B.begin(),B.end());
        int cntA=0,cntB=0;

        bool flag=true;
        for(int i=0;i<A.size();i++)
        {
            if(A[i].x>cntA) {flag=false;break;}
            cntA+=A[i].y;
        }

        for(int i=0;i<B.size();i++)
        {
            if(B[i].x>cntB) {flag=false;break;}
            cntB+=B[i].y;
        }

        if(cntA!=cntB) flag=false;
        printf("%s\n",flag?"Yes":"No");
    }
    return 0;
}