#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#define fs(i,x,y) for(int i=(x),_=(y);i<=_;++i)
#define fn(i,x,y) for(int i=(x),_=(y);i>=_;--i)
#define tor(i,v,x) for(int i=head[x],v=to[i];i;i=nxt[i],v=to[i])
#define Li inline
#define R register int
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define mpi(x,y) make_pair(x,y)
#define pi pair<int,int>
#define int ll 
using namespace std;
typedef long long ll;
template<typename T>
void read(T &x){
	x=0;char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	x=f?-x:x;
}

const int N=2e5+7;
int n,m;
int a[N];
int now;

bool cmp(int x,int y){
	return x>y;
}

signed main(){
	read(n);fs(i,1,n){
		int x,y;read(x);read(y);
		a[i]=x*2+y;now+=x;
	}
	sort(a+1,a+n+1,cmp);
	fs(i,1,n){
		now-=a[i];if(now<0){
			cout<<i;return 0;
		}
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 5;

int N, M;
int a[MAXN][2];
vector <pair <int, int>> adj[MAXN];
int bio[MAXN], ans[MAXN];
int c[MAXN];

void load() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++)
    for (int j = 0; j < 2; j++)
      scanf("%d", a[i] + j);
  for (int i = 1; i <= N; i++)
    scanf("%d", c + i);
}

void dfs(int x, int p) {
  bio[x] = 1;
  for (auto it : adj[x]) {
    int nxt = a[it.first][it.second];
    if (nxt == p || bio[nxt] == 2)
      continue;
    ans[it.first] = it.second;
    if (!bio[nxt])
      dfs(nxt, x);
  }
  bio[x] = 2;
}

void solve() {
  for (int i = 0; i < M; i++)
    if (c[a[i][0]] != c[a[i][1]])
      ans[i] = c[a[i][0]] > c[a[i][1]];
    else
      for (int j = 0; j < 2; j++)
        adj[a[i][j]].push_back({i, j ^ 1});
  for (int i = 1; i <= N; i++)
    if (!bio[i])
      dfs(i, 0);
  for (int i = 0; i < M; i++)
    printf("%s\n", ans[i] ? "->" : "<-");
}

int main() {
  load();
  solve();
  return 0;
}