Example

Input

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


Output

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

char s[100][102];
pair<int,int> p[102];
const int inf=(~0u)>>2;
vector<pair<int,int> > s1,s2,s3;
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
bool cmp(pair<int,int> a,pair<int,int> b)
{
	return a.FI-a.SE<b.FI-b.SE;
}
bool check()
{
	int n,len;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
	{
		scanf("%s",s[i]);
		len=strlen(s[i]);
		int minv=inf,val=0;
		for(int j=0;j<len;++j)
		{
			if(s[i][j]=='(')++val;
			else --val;
			minv=min(minv,val);
		}
		p[i]=MP(minv,val);
		//cout <<minv<<" "<<val<<endl;
		if(minv>=0)s1.PB(p[i]);
		else if(val>=0)s2.PB(p[i]);
		else s3.PB(p[i]);
	}
	//for(auto i:s1)cout <<i.FI<<" "<<i.SE<<endl;
	//for(auto i:s2)cout <<i.FI<<" "<<i.SE<<endl;
	int sum=0;
	for(int i=0;i<s1.size();++i)
		sum+=s1[i].SE;
	//cout <<"s2 begin:"<<sum<<endl;
	sort(s2.begin(),s2.end());
	reverse(s2.begin(),s2.end());
	for(int i=0;i<s2.size();++i)
	{
		if(s2[i].FI+sum<0)return false;
		sum+=s2[i].SE;
	}
	//cout <<"s3 begin:"<<sum<<endl;
	sort(s3.begin(),s3.end(),cmp);
	//for(auto i:s3)cout <<i.FI<<" "<<i.SE<<endl;
	for(int i=0;i<s3.size();++i)
	{
		if(s3[i].FI+sum<0)return false;
		sum+=s3[i].SE;
		if(sum<0)return false;
	}
	//cout <<sum<<endl;
	return sum==0;
}
int main()
{
	if(check())puts("Yes");		
	else puts("No");
	return 0;
}