Example

Input

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


Output

Yes
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int u[100], v[100], n; bool used[100];
vector<pair<int, int>>vec, vec2;
bool solve(vector<pair<int, int>>x) {
	for (int i = 0; i < 100; i++)used[i] = false;
	int r = 0;
	for (int i = 0; i < x.size(); i++) {
		int maxn = -10000, maxid = 0;
		for (int j = 0; j < x.size(); j++) {
			if (used[j] == true)continue;
			if (r + x[j].second < 0)continue;
			if (maxn < x[j].first) { maxn = x[j].first; maxid = j; }
		}
		if (maxn == -10000) {
			return false;
		}
		r += x[maxid].first; used[maxid] = true;
	}
	return true;
};
int main() {
	cin >> n; int E = 0;
	for (int i = 0; i < n; i++) {
		string S; cin >> S; int cnt = 0, minx = 0;
		for (int j = 0; j < S.size(); j++) {
			if (S[j] == '(')cnt++; if (S[j] == ')')cnt--;
			minx = min(minx, cnt);
		}
		u[i] = cnt; v[i] = minx;
		E += cnt;
		if (u[i] >= 0)vec.push_back(make_pair(u[i], v[i]));
		else { v[i] = v[i] - u[i]; u[i] *= -1; vec2.push_back(make_pair(u[i], v[i])); }
	}
	if (E != 0) { cout << "No" << endl; return 0; }
	bool ans = solve(vec), ans2 = solve(vec2);
	if (ans == true && ans2 == true)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}