#include <bits/stdc++.h>
using namespace std;
int n,m,a[200050],dp[200050],ans=-2e9;
vector<int> e[200050];
bool vis[200050];

void dfs(int x) {
	if (vis[x]) return;
	vis[x]=1;
	for (int i:e[x]) {
		dfs(i); dp[x]=max(dp[x],dp[i]);
	}
	ans=max(ans,dp[x]-a[x]);
	dp[x]=max(dp[x],a[x]);
}

int main() {
	cin>>n>>m;
	for (int i=1; i<=n; ++i)
		scanf("%d",a+i),dp[i]=-1e9;
	while (m--) {
		int x,y; scanf("%d%d",&x,&y);
		e[x].push_back(y);
	}
	for (int i=1; i<=n; ++i)
		if (!vis[i]) dfs(i);
	cout<<ans;
}
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

map<int, int> rev;
const int N = 102;
const int M = 102102;
vi vis(N), ans(M), ok(M);
vii ed(M);

void dfs(vector<vii> &gr, int u, int p) {
  vis[u] = 1;
  for (auto [v, e]: gr[u]) if (p != v) {
    if (vis[v]) {
      ok[rev[e]] = 1;
      ans[rev[e]] = ed[rev[e]].fst == v;
    }
    else {
      ans[rev[e]] = ed[rev[e]].snd == v;
      ok[rev[e]] = 1;
      dfs(gr, v, u);
    }
  }
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n, m;
  cin >> n >> m;

  vi c(n+1), done(m), vis(n+1);

  vector<vii> g(n+1);
  rep(i,0,m) {
    cin >> ed[i].first >> ed[i].second;
    g[ed[i].fst].eb(ed[i].snd, i);
    g[ed[i].snd].eb(ed[i].fst, i);
  }

  rep(i,1,n+1) cin >> c[i];

  rep(i,1,n+1) {
    if (vis[i]) continue;
    queue<int> q;
    q.push(i);
    vis[i] = 1;
    vi comp;
    while (!q.empty()) {
      int u = q.front(); q.pop();
      comp.pb(u);
      for (auto [v, j]: g[u]) if (!vis[v] && c[v] == c[u]) {
        vis[v] = 1;
        q.push(v);
      }
    }

    vector<vii> gr(n+1);
    int nedges = 0;
    for (auto u: comp) {
      for (auto [v, j]: g[u]) {
        if (c[u] == c[v] && !done[j]) {
          rev[nedges] = j;
          gr[u].eb(v, nedges);
          gr[v].eb(u, nedges);
          ++nedges;
          done[j] = 1;
        }
      }
    }

    dfs(gr, i, i);
  }

  rep(i,0,m) {
    if (!ok[i]) {
      assert(c[ed[i].fst] != c[ed[i].snd]);
      ans[i] = c[ed[i].fst] > c[ed[i].snd];
    }
    if (ans[i]) cout << "->";
    else cout << "<-";
    cout << '\n';
  }

}