Example

Input

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


Output

Yes
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N; cin >> N;
	vector < pair<int, int>>ps;
	for (int i = 0; i < N; ++i) {
		string st; cin >> st;
		int sum = 0;
		int amin = 0;
		int amax = 0;
		for (int j = 0; j < st.size(); ++j) {
			if (st[j] == '(') {
				sum++;
			}
			else {
				sum--;
				amin = min(amin, sum);
			}
		}
		ps.push_back(make_pair(-amin, sum));
	}
	int nsum = 0;
	sort(ps.begin(), ps.end(), [](const pair<int, int>&l, const pair<int, int>&r) {	
		if (l.second >= 0 && r.second >= 0) {
			return l.first < r.first;
		}
		else if (l.second < 0 && r.second < 0) {
			return  l.first + l.second >r.first + r.second;

		}
		else if(l.second>=0){
			return true;
		}
		else {
			return false;
		}
		});
	bool ok = true;
	for (auto p : ps) {
		if (nsum >= p.first) {
			nsum += p.second;
		}
		else {
			ok = false;
		}
		if (nsum < 0)ok = false;
	}
	if (ok&&!nsum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}