#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
#include <utility>


using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

void dfs(int ter,vector<vector<tuple<int,int,int>>>&go,vector<int>&ans){
	for(auto it:go[ter]){
		if(ans[get<1>(it)]!=-1){continue;}
		ans[get<1>(it)]=get<2>(it);
		dfs(get<0>(it),go,ans);
	}
}
int main(void){
	int i,n,m;cin>>n>>m;
	vector<char>L(n);
	vector<pair<int,int>>road(m);
	vector<vector<tuple<int,int,int>>>go(n);
	vector<int>ans(m,-1);
	vector<int>c(n);
	for(i=0;i<m;i++){
		int a,b;cin>>a>>b;a--;b--;
		road[i]=mp(a,b);
	}
	for(i=0;i<n;i++){cin>>c[i];}
	for(i=0;i<m;i++){
		int a,b;tie(a,b)=road[i];
		if(c[a]!=c[b]){continue;}
		go[a].pub({b,i,0});
		go[b].pub({a,i,1});
	}
	vector<int>d(n);
	for(i=0;i<n;i++){
		if(L[i]==0&&go[i].size()>0){//ここを出発点とする
			dfs(i,go,ans);
		}
	}
	for(i=0;i<m;i++){
		int a,b;tie(a,b)=road[i];
		if(c[a]>c[b]){cout<<"->"<<endl;}
		else if(c[a]<c[b]){cout<<"<-"<<endl;}
		else {cout<<(ans[i]?"<-":"->")<<endl;}
	}
}

#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   Y            imag()
#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<long double>
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-15);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const ll N=200000+5,mod=998244353,sh=1000000,inf=100000000;
int mem[N],a[N];
vector<int> v[N];
int solve(int no){

   int &ret=mem[no];
   if(ret!=-1) return ret;
   int ans=0;
   for(int i=0;i<sz(v[no]);i++){
    int nw=v[no][i];
    ans=max(ans,max(a[nw],solve(nw)));
   }
   return ret=ans;

}
int main(){
    GO();
    int T=1;
  //  cin>>T;
    while(T--){

       int n,m;
       cin>>n>>m;
       for(int i=1;i<=n;i++) cin>>a[i];
       for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
       }
       clr(mem,-1);
       int ans=INT_MIN;
       for(int i=1;i<=n;i++){
        if(solve(i)==0) continue;
         ans=max(ans,solve(i)-a[i]);
       }
       cout<<ans<<"\n";


    }
}

















