Example

Input

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


Output

Yes
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[109], b[109]; string s;
int main() {
	cin >> n;
	int sumd = 0;
	for (int i = 0; i < n; i++) {
		cin >> s;
		int d = 0; b[i] = 0;
		for (int j = 0; j < s.size(); j++) {
			if (s[j] == '(') d++;
			if (s[j] == ')') d--;
			b[i] = max(b[i], -d);
		}
		a[i] = d;
		sumd += d;
	}
	vector<pair<int, int> > ls, rs;
	for (int i = 0; i < n; i++) {
		if (a[i] >= 0) ls.push_back(make_pair(b[i], a[i]));
		else rs.push_back(make_pair(b[i] + a[i], -a[i]));
	}
	sort(ls.begin(), ls.end());
	sort(rs.begin(), rs.end());
	bool ok = (sumd == 0);
	int lx = 0;
	for (int i = 0; i < ls.size(); i++) {
		if (lx - ls[i].first < 0) ok = false;
		lx += ls[i].second;
	}
	int rx = 0;
	for (int i = 0; i < rs.size(); i++) {
		if (rx - rs[i].first < 0) ok = false;
		rx += rs[i].second;
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}