#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <string.h>
using namespace std;
#define ll long long
#define INF 1000007
#define MAX 500007
#define EPS 1e-9
#define PI acos(-1.0)
#define nl "\n"
#define F first
#define S second
typedef vector<ll> vi;
typedef priority_queue<ll , vector<ll> , greater<ll> > pqmx;
typedef priority_queue<ll> pqmn;
typedef pair<ll , ll> pi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector< pair<int , int> > vpi;
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define yeS(GOOD)      GOOD ? cout<<"YES\n" : cout<<"NO\n"
#define all(a) a.begin() , a.end()
#define pb push_back
#define ar array
ll mod = LLONG_MAX;
ll binpow(ll a, ll b){ll res=1;a%=mod;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
ll binmul(ll a, ll b){ll res=0;a%=mod;while(b>0){if(b&1)res=(res + a)%mod;a=(a + a)%mod;b>>=1;}return res;}
ll area(pi a, pi b,pi c){return abs(a.F * b.S + b.F * c.S + c.F*a.S - a.S * b.F - b.S * c.F - c.S * a.F);}
ll gcd (ll a,ll b){if(b==0)return a;else return gcd (b, a % b);}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll min(ll a,ll b){if(a < b){return a;}return b;}
ll max(ll a,ll b){if(a > b){return a;}return b;}
double intlog(ll n ,ll base){return (double)log(n)/log(base);}
double DEG_to_RAD(double d) { return d * PI / 180.0; }
double RAD_to_DEG(double r) { return r * 180.0 / PI; }

ll n , t , m , temp , temp2, root , p ,q , k , i , j , r , u , v , w;

int dp[1005][1005];

int solve(int i,int j,vi & a,vi & b){
    if(i == n && j == m)return 0;
    if(i == n)return solve(i,j+1,a,b) + 1;
    if(j == m)return solve(i+1,j,a,b) + 1;
    if(dp[i][j] != -1)return dp[i][j];
    int res = INT_MAX;
    if(a[i] == b[j]){
        res = min(solve(i+1,j+1,a,b),res);
    }
    res = min(res, solve(i+1,j,a,b)+1);
    res = min(res, solve(i,j+1,a,b)+1);
    res = min(res, solve(i+1,j+1,a,b)+1);
    return dp[i][j] = res;
}


int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" ,stdin);
    freopen("output.txt" , "w" , stdout);
#endif
    cin>>n>>m>>p>>q;
    int dp[n][m];
    memset(dp,-1,sizeof(dp));
    vpi a;
    fr(i , p){
        cin>>u>>v;
        a.pb({u-1,v-1});
    }
    fr(i , q){
        cin>>u>>v;
        dp[u-1][v-1] = 4;
    }
    int res = 0;
    fr(i , a.size()){
        int x = a[i].F;
        int y = a[i].S;
        if(dp[x][y] != 1 && dp[x][y] != 3){
            p = x;
            q = y;
            while(p < n && dp[p][q] != 4){
                if(dp[p][q] == 2)dp[p][q] = 3;
                else dp[p][q] = 1;
                p++;
            }
            p = x;
            q = y;
            while(p >= 0 && dp[p][q] != 4){
                if(dp[p][q] == 2)dp[p][q] = 3;
                else dp[p][q] = 1;
                p--;
            }
        }
        if(dp[x][y] != 2 && dp[x][y] != 3){
            p = x;
            q = y;
            while(q < m && dp[p][q] != 4){
                if(dp[p][q] == 1)dp[p][q] = 3;
                else dp[p][q] = 2;
                q++;
            }
            p = x;
            q = y;
            while(q >= 0 && dp[p][q] != 4){
                if(dp[p][q] == 1)dp[p][q] = 3;
                else dp[p][q] = 2;
                q--;
            }
        }
    }
    fr(i , n){
        fr(j , m){
            if(dp[i][j] == 1 || dp[i][j] == 2 || dp[i][j] == 3){
                res++;
            }
              //  cout<<dp[i][j]<<" ";
        }
        //cout<<nl;
    }
    cout<<res<<nl;
#ifndef ONLINE_JUDGE
    cout << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s .\n";
#endif
}

#include<bits/stdc++.h>
#define pb push_back
using namespace std;
#define G getchar()
int read()
{
	int x=0; bool flg=false; char ch=G;
	for (;!isdigit(ch);ch=G) if (ch=='-') flg=true;
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return flg?-x:x;
}
#undef G
#define fi first
#define se second
typedef long long ll;
const int mod=998244353;
inline int upd(const int &x){return x+(x>>31&mod);}
inline void add(int &x,int y){x=upd(x+y-mod);}
inline void iadd(int &x,int y){x=upd(x-y);}
int qpow(int x,int y){
	int res=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1) res=1LL*res*x%mod;
	return res;
}
#define rep(i,l,r) for (int i(l);i<=r;i++)
#define per(i,l,r) for (int i(r);i>=l;i--)

int n,m,a[10010],b[10010],c[110];
bool vis[110];
int dir[110][110];
vector<int> e[110];
void dfs(int x){
	vis[x]=1;
	for (int y: e[x]){
		if (c[y]^c[x]) continue;
		if (!vis[y]) dir[x][y]=1,dir[y][x]=-1,dfs(y);
		else dir[x][y]=-1,dir[y][x]=1;
	}
}
void solve(){
	n=read(),m=read();
	rep(i,1,m) a[i]=read(),b[i]=read(),e[a[i]].pb(b[i]),e[b[i]].pb(a[i]);
	rep(i,1,n) c[i]=read();
	rep(i,1,n) if (!vis[i]) dfs(i);
	rep(i,1,m){
		if (c[a[i]]<c[b[i]]) puts("<-");
		else if (c[a[i]]>c[b[i]]) puts("->");
		else if (dir[a[i]][b[i]]==1) puts("->");
		else puts("<-");
	}
}
int main()
{
	for (int T=1;T--;) solve();
}
