#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<(n);i++)
#define rep2(i,n,m) for(ll i=n;i<(m);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
void YES(int a){
  if(a) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
void Yes(int a){
  if(a) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

//#include <atcoder/all>

//using namespace atcoder;
//typedef modint998244353 mint;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  VI A(N),P(N),X(N);
  rep(i,N) cin>>A[i]>>P[i]>>X[i];
  int ans=1001001001;
  rep(i,N){
    if(A[i]<X[i]) ans=min(ans,P[i]);
  }
  if(ans==1001001001) cout<<-1<<endl;
  else cout<<ans<<endl;
}

#include<iostream>
#include<cstring>
#include<cassert>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<bitset>
#include<cstdio>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(int i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const int N=1e4+7;
const int INF=1e9+7;
int n,m,num=0,cnt=0;
int pos[N],X[N],Y[N],D[N*2],c[N],vis[N];
struct edge{int v,next,c;}e[N*2];
void add(int x,int y,int c){e[num]=(edge){y,pos[x],c}; pos[x]=num++;}
void dfs(int x,int f){
	vis[x]=++cnt;
	repG(i,x){
		if(e[i].v==f)continue;
		if(vis[e[i].v]){
			if(vis[e[i].v]<vis[x])D[e[i].c]=1;
		}
		else{
			dfs(e[i].v,x);
			D[e[i].c]=1;
		}
	}
}
int main(){
	memset(pos,-1,sizeof(pos));
	scanf("%d%d",&n,&m);
	rep(i,m)scanf("%d%d",&X[i],&Y[i]);
	rep(i,n)scanf("%d",&c[i]);
	rep(i,m){
		if(c[X[i]]!=c[Y[i]]){
			if(c[X[i]]>c[Y[i]])D[i*2-1]=1;
			else D[i*2]=1;
		}
		else {
			add(X[i],Y[i],i*2-1);
			add(Y[i],X[i],i*2);
		}
	}
	rep(i,n)if(!vis[i])dfs(i,0);
	rep(i,m){
		if(D[i*2-1])puts("->");
		else puts("<-");
	}
	return 0;
}
