#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll n, a[400020];
vector<pair<ll, ll>> v;
queue<int> pos;
string ans;

int main() {
    scanf("%lld", &n);
    ans.resize(2*n, 'p');
    for(int i = 0; i < 2*n; i++) {
        scanf("%lld", &a[i]);
        v.emplace_back(a[i], i);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++) a[v[i].second] = 0;
    for(int i = 0; i < 2*n; i++) {
        if(pos.empty()) pos.push(i);
        else if((a[i] && a[pos.front()]) || (!a[i] && !a[pos.front()])) pos.push(i);
        else {
            ans[pos.front()] = '(';
            ans[i] = ')';
            pos.pop();
        }
    }
    printf("%s\n", ans.c_str());
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	vector<ll> dp(2, 1);
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		vector<ll> p(2);
		swap(dp, p);
		if (s == "AND") {
			dp[0] = 2 * p[0] + p[1];
			dp[1] = p[1];
		} else {
			dp[0] = p[0];
			dp[1] = p[0] + 2 * p[1];
		}
	}
	cout << dp[1] << endl;
}