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>>;


int main() {
	int N; cin >> N;
	vector<pair<int, int>>ups;
	vector<pair<int, int>>downs;
	for (int i = 0; i < N; ++i) {
		string st; cin >> st;
		int left = 0;
		int right = 0;
		for (int i = 0; i < st.size(); ++i) {
			if (st[i] == '(') {
				right++;
			}
			else {
				right--;
				left = min(left, right);
			}
		}
		left = -left;
		if (right >= 0) {
			ups.push_back(make_pair(left, right));
		}
		else {
			downs.push_back(make_pair(left, right));
		}
	}
	sort(ups.begin(), ups.end());
	int num = 0;
	bool ok = true;
	auto it = ups.begin();
	while (it != ups.end()) {
		if (num >= it->first) {
			num += it->second;
		}
		else {
			ok = false;
			break;
		}
		it++;
	}
	sort(downs.begin(), downs.end(), [](const pair<int, int>&l, const pair<int, int>&r) {
		return l.first + l.second > r.first + r.second;
	});
	auto jt = downs.begin();
	while (jt != downs.end()) {
		if (num >= jt->first) {
			num += jt->second;
		}
		else {
			ok = false;
			break;
		}
		jt++;
	}
	if (num != 0)ok = false;
	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}