Example

Input

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


Output

Yes
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
const ll N=1e3+10;
const ll P=1e9+7;
struct node{int r,l;};
bool operator<(node a,node b){return a.l<b.l||(a.l==b.l&&a.r<b.r);}
bool cmp(node a,node b){return a.r<b.r;}
vector<node>v,v1;
int main()
{
    string s;
    int n,i,j;
    cin>>n;v.clear();v1.clear();
    for(i=0;i<n;i++)
    {
        cin>>s;int x=0,y=0;
        for(j=0;j<s.length();j++)
        {
            if(s[j]=='(')x++;
            else if(x)x--;else y++;
        }
        if(x>y)v.push_back(node{y,x});
        else v1.push_back(node{y,x});
    }
    sort(v.begin(),v.end(),cmp);
    sort(v1.begin(),v1.end());
    int sum=0;
    for(i=0;i<v.size();i++)
    if(sum<v[i].r){printf("No\n");return 0;}
    else sum+=(v[i].l-v[i].r);
    for(i=v1.size()-1;i>=0;i--)
    if(sum<v1[i].r){printf("No\n");return 0;}
    else sum+=(v1[i].l-v1[i].r);
    if(sum==0)printf("Yes");
    else printf("No");
    printf("\n");
    return 0;
}