// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;

void _plus(long long &v, long long p, long long X)
{
  v += p;
  if (v < 0)
  {
    v += X;
  }
  else
  {
    v = v % X;
  }
}

typedef pair<int, int> ii;
typedef vector<int> iv;

template <typename T>
void print_vec(vector<T> v)
{
  for (auto const &x : v)
  {
    cout << x << " : ";
  }
  cout << "" << endl;
}

int N, M, a, b;
iv clist, checklist, ans;
vector<iv> table;
vector<ii> ablist;

void dfs(int i)
{
  checklist[i] = 1;
  for (int j = 1; j <= N; j++)
  {
    const int pid = table[i][j];
    if (j == i || pid == -1 || ans[pid] != 0)
    {
      continue;
    }

    if (clist[i] != clist[j])
    {
      ans[pid] = clist[i] < clist[j] ? 1 : -1;
      if (ablist[pid].first == j)
      {
        ans[pid] = -ans[pid];
      }
      continue;
    }

    ans[pid] = -1;
    if (ablist[pid].first == j)
    {
      ans[pid] = -ans[pid];
    }

    if (!checklist[j])
    {
      dfs(j);
    }
  }
}

int main()
{
  cin >> N >> M;

  for (int i = 0; i <= N; i++)
  {
    table.emplace_back(vector<int>(N + 1, -1));
  }

  clist = iv(N + 1, 0);
  checklist = iv(N + 1, 0);
  ans = iv(M, 0);

  for (int i = 0; i < M; i++)
  {
    cin >> a >> b;
    ablist.emplace_back(ii(a, b));
    table[a][b] = i;
    table[b][a] = i;
  }
  for (int i = 1; i <= N; i++)
  {
    cin >> clist[i];
  }

  for (int i = 1; i <= N; i++)
  {
    if (checklist[i])
    {
      continue;
    }
    checklist[i] = 1;

    dfs(i);
  }

  for (int i = 0; i < M; i++)
  {
    cout << (ans[i] == -1 ? "->" : (ans[i] == 1 ? "<-" : "err")) << endl;
  }
}
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define np next_permutation
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define vii vector<vi>
#define vb vector<bool>
#define pr pair<int,int>
#define vl vector<ll>
#define vs vector<string>
#define us unordered_map<int,int>
#define Mpq priority_queue<int>
#define mpq priority_queue<int,vi,greater<int>> 
#define eb emplace_back
#define pr pair<int,int>
#define prl pair<ll,ll>
#define vp vector<pr>
#define vpl vector<prl>
#define mkp make_pair
#define ld long double
#define vii vector<vi>
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define ull unsigned long long
#define prr pair<ll,int>
#define inf (int)1e9+111
 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using vi=vector<int>;
 
typedef tree<
pair <int,int>, null_type,
less<pair <int,int>>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;
ordered_set s;
 
#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
template<class T> using pqg = priority_queue<T,vector<T>,greater<T>>;
 
double epsilon=(double)1e-9;
 
const int N=2e6;
ll n,m,k,x,y,t,sum,prev_e,tot,val,pos=1;
ll last_room,rooms;
string pattern,word;
const int Max=(int)1e5;
 
 
int ver[4]={1,-1,0,0},hor[4]={0,0,1,-1};
string MV="DURL",moves;
 
const ll MX=(ll)1e16+123;
 
template<int N> struct Dij{
   ll d[N];
   vector<pair<ll,prl>> g[N];
   pqg<prl> q;
 
   void addEdge(ll a,ll b,ll c,ll d){
      g[a].pb(make_pair(b,make_pair(c,d)));
      g[b].pb(make_pair(a,make_pair(c,d)));
   }
   
   void algo(int s){
      fill_n(d,N,MX);
      q=pqg<prl>();
      q.push({d[s]=0,s});
 
      while(!q.empty()){
         auto x=q.top();
         q.pop();
         if(d[x.S]<x.F) continue;
         for(auto &y:g[x.S]){
            ll distance=ceil((double)x.F/(double)y.S.S)*y.S.S+y.S.F;
            if(distance<d[y.F]){
               q.push({d[y.F]=distance,y.F});
            }
         }
      }
   }
};
 
Dij<N> D;
int a[N];
vi g[N];

void solve(){
   int n,m,ans=-1;
   cin>>n>>m;
   lp(i,n){
     cin>>x;
     g[x].eb(i);
   }

   lp(i,n){
     int j=0;
     if(g[i].empty()){
       ans=i;
       break;
     }
     for(auto &v:g[i]){
        if(v>m-1+j){
          ans=i;
          break;
        }
        j=v+1;
     }
     if(m-1+j<n) ans=i;
     if(ans>=0) break;
   }
   if(ans<0) ans=n;
   cout<<ans<<"\n";
}
 
int main(){
   ios_base::sync_with_stdio(0);  
   cin.tie(nullptr);
   solve(); 
   return 0;
}
