#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define read read1<ll>()
# define Type template<typename T>
Type T read1(){
	T t=0;
	char k;
	bool vis=0;
	do (k=getchar())=='-'&&(vis=1);while('0'>k||k>'9');
	while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
	return vis?-t:t;
}
# define fre(k) freopen(k".in","r",stdin);freopen(k".out","w",stdout)
char Str[400005];
int a[400005],s,b[400005];;
bool vis[400005];
int sta[400005];
int main(){
	s=read;int n=s*2;
	for(int i=1;i<=n;++i)a[i]=read,b[i]=i;
	nth_element(b+1,b+s+1,b+n+1,[&](const int &x,const int &y){return a[x]<a[y];});
	for(int i=1;i<=s;++i)vis[b[i]]=1;
	for(int i=1;i<=n;++i){
		if(!*sta)sta[++*sta]=i,Str[i]='(';
		else{
			if(vis[sta[*sta]]^vis[i])--*sta,Str[i]=')';
			else sta[++*sta]=i,Str[i]='(';
		}
	}puts(Str+1);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define printg(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int get_random() {
    static uniform_int_distribution<int> dist(0, 1e9 + 6);
    return dist(rng);
}
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}


typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

template<class T>
void make_unique(T & v) {
    sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
}
int geti() { int x; cin >> x; return x; }
long long getll() { long long x; cin >> x; return x; }
double getd() { double x; cin >> x; return x; }
// pair<int, int> a(geti(), geti()) does not work
// pair<int, int> a({geti(), geti()}) works, since it uses initializer.

const int MAXN = 3e5 + 100;

void solve(int tt) {
    // cout<<"Case #"<<tt<<": ";
}

array<int,3> e[MAXN];
int c[MAXN],vis[MAXN]={};

vpii graph[MAXN];

void dfs(int i, int p) {
	vis[i]=1;
	print("vis",i);
	for(auto [j,idx]:graph[i]) {
		if(j==p)continue;
		if(c[j]>c[i]) continue;
		print(i,j);

		if(e[idx][2]<0) {
			if(e[idx][0] == i) e[idx][2]=1;
			else e[idx][2]=0;
		}
		if(!vis[j]) dfs(j,i);
	}
}

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // solve_testcase;

    int n,m;
    cin>>n>>m;
    int u,v;
    rep(i,0,m){
    	cin>>u>>v;
    	e[i][0] = u;
    	e[i][1] = v;
    	e[i][2] = -1;
    	graph[u].pb({v,i});
    	graph[v].pb({u,i});
    }
    rep(i,1,n+1) {
    	cin>>c[i];
    }
    rep(i,1,n+1) {
    	if(!vis[i]) dfs(i,-1);
    }
    printn(e,m);
    rep(i,0,m) {
    	if(e[i][2]==1)cout<<"->"<<endl;
    	else cout<<"<-"<<endl;
    }

    return 0;
}











