/*
problem : arc 120 D 
algorithm :stack
created : Programmer_juruo
*/

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

#define int long long
#define N 2000005
#define M 2005
#define lowbit(x) x & (-x)
#define F1(i, n) for(int i = 1; i <= n; i++)
#define F(i, a, n) for(int i = a; i <= n; i++)
#define F0(i, n) for(int i = 0; i < n; i++)
#define dbg(x) cout << #x << ":" << x << endl;
#define se second
#define fi first
#define y1 juruo
#define mp make_pair
#define pb push_back
#define arr vector<int>
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

typedef pair <int, int> pii;
typedef priority_queue <int> pq;
typedef long long ll;

const int inf = 0x3f3f3f3f;
const int p = 107;
const int P = 100007;
const int Mod = 1e9+7;

int n, m;
int b[N];
vector <pii> ar;
void work() {
	cin >> n;
	vector <int> a(2*n);
	for(int i = 0; i < 2*n; i++) {
		cin >> a[i];
		ar.push_back(pii(a[i], i));
	}
	
	sort(ar.begin(), ar.end());
	
	for(int i = 0; i < n; i++) {
		b[ar[i].se] = 1;
	}
	string s(2*n, '~');
	stack <int> S;
	for(int i = 0; i < 2*n; i++) {
		if(!S.empty() && b[i] + b[S.top()] == 1) {
			s[i] = ')';
			s[S.top()] = '(';
			//ok
			S.pop();
		}else {
			//not pair with anybody
			S.push(i);
		}
	}
	cout << s << endl;
}

signed main() {
  //freopen("1.in", "r", stdin);
  //freopen("1.out", "w", stdout);
  int T = 1;

  //cin >> T;

  while(T--) {
  	work();
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int O = 2e5 + 1;

int t = 1;

vector <int> c, dp, g[O], Max;

bool how_sort(int x, int y){
    return Max[x] < Max[y];
}

int dfs(int u, int par = 0){
    Max[u] = 0;
    for (int v : g[u]){
        if (v == par) continue;
        dp[v] = dp[u] + 1;
        Max[u] = max(Max[u], dfs(v, u) + 1);
    }
    return Max[u];
}

void dfs1(int u, int par = 0){
    c[u] = t;
    int m = 0;
    for (int v : g[u]){
        if (v == par) continue;
        t += 1;
        dfs1(v, u);
        t += 1;
    }
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    c.resize(n + 1);
    dp.resize(n + 1);
    Max.resize(n + 1);
    for (int i = 1; i < n; ++ i){
        int u, v; cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
    int compare = 0;
    int root = 1;
    for (int i = 1; i <= n; ++ i){
        if (dp[i] > compare){
            compare = dp[i];
            root = i;
        }
    }
    dfs(root);
    for (int i = 1; i <= n; ++ i){
        sort(g[i].begin(), g[i].end(), how_sort);
    }
    dfs1(root);
    for (int i = 1; i <= n; ++ i) cout << c[i] << " ";
}
