Example

Input

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


Output

Yes
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;

struct node
{
    int l;
    int r;
}num[110];

int n,clen,cal,ans,flag;
char c[110];

bool cmp(node a,node b)
{
    if(a.l<=a.r)
    {
        if(b.l<=b.r)return a.l<b.l;
        else return 1;
    }
    else
    {
        if(b.l<=b.r)return 0;
        else return a.r>b.r;
    }
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s",c);
        clen=strlen(c);
        cal=0;
        for(int j=0;j<clen;j++)
        {
            if(c[j]=='(')cal++;
            else
            {
                cal--;
                if(cal<0){num[i].l++;cal=0;}
            }
        }
        cal=0;
        for(int j=clen-1;j>=0;j--)
        {
            if(c[j]==')')cal++;
            else
            {
                cal--;
                if(cal<0){num[i].r++;cal=0;}
            }
        }
    }
    sort(num,num+n,cmp);
    for(int i=0;i<n;i++)
    {
        ans=ans-num[i].l;
        if(ans<0)
        {
            flag=1;
            break;
        }
        ans=ans+num[i].r;
    }
    if(ans!=0 || flag==1)printf("No\n");
    else printf("Yes\n");
    return 0;
}