Problem: Urpal lives in a big city. He has planned to meet his lover tonight. 

The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in a restaurant in junction b. He wants to use public transportation to get to junction b. There are k bus transportation companies. At the beginning of every second, a bus from the i-th company chooses a random shortest path between junction si and junction ti and passes through it. There might be no path from si to ti. In that case no bus will leave from si to ti. If a bus passes through a junction where Urpal stands, he can get on the bus. He can also get off the bus at any junction along the path. 

Now Urpal wants to know if it's possible to go to the date using public transportation in a finite amount of time (the time of travel is the sum of length of the traveled roads) and what is the minimum number of buses he should take in the worst case.

At any moment Urpal knows only his own position and the place where the date will be. When he gets on the bus he knows only the index of the company of this bus. Of course Urpal knows the city map and the the pairs (si, ti) for each company.

Note that Urpal doesn't know buses velocity. 

Input

The first line of the input contains four integers n, m, a, b (2 ≤ n ≤ 100; 0 ≤ m ≤ n·(n - 1); 1 ≤ a, b ≤ n; a ≠ b). 

The next m lines contain two integers each ui and vi (1 ≤ ui, vi ≤ n; ui ≠ vi) describing a directed road from junction ui to junction vi. All roads in the input will be distinct. 

The next line contains an integer k (0 ≤ k ≤ 100). There will be k lines after this, each containing two integers si and ti (1 ≤ si, ti ≤ n; si ≠ ti) saying there is a bus route starting at si and ending at ti. Please note that there might be no path from si to ti, this case is described in the problem statement.

Output

In the only line of output print the minimum number of buses Urpal should get on on his way in the worst case. If it's not possible to reach the destination in the worst case print -1.

Examples

Input

7 8 1 7
1 2
1 3
2 4
3 4
4 6
4 5
6 7
5 7
3
2 7
1 4
5 7


Output

2


Input

4 4 1 2
1 2
1 3
2 4
3 4
1
1 4


Output

-1

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class CF148E implements Runnable {
	
	private Edge first[];
	private boolean vis[];
	int ban;
	
	class Edge
	{
		Edge next;
		int u, v;
		
		Edge()
		{
			
		}
		
		Edge(int from, int to)
		{
			u = from;
			v = to;
			next = first[from];
			first[from] = this;
		}
	}
		
	private void dfs(int u)
	{
		if (u == ban)
			return;
		vis[u] = true;
		for (Edge e = first[u]; e != null; e = e.next)
			if (!vis[e.v])
				dfs(e.v);
	}
	
	private boolean reach(int u, int v)
	{
		Arrays.fill(vis, false);
		dfs(u);
		return vis[v];
	}
	
	int d[];
	
	private int distance(int u, int v)
	{
		Queue<Integer> Q = new LinkedList<Integer>();
		Arrays.fill(vis, false);
		Arrays.fill(d, Integer.MAX_VALUE);
		d[u] = 0;
		Q.offer(u);
		while (!Q.isEmpty())
		{
			int now = Q.poll();
			for (Edge e = first[now]; e != null; e = e.next)
				if (e.v != ban && d[e.v] > d[now] + 1)
				{
					d[e.v] = d[now] + 1;
					Q.offer(e.v);
				}
		}
		
		return d[v];
	}
	
	boolean memo[][];
	int dp[][];
	ArrayList<Integer> keyPoint[][];
	
    private void solve() throws IOException {
    	int n, m, a, b;
    	n = nextInt();
    	m = nextInt();
    	a = nextInt();
    	b = nextInt();
    	--a;
    	--b;
    	ban = -1;
    	first = new Edge[n];
    	d = new int[n];
    	vis = new boolean[n];
    	
    	final int INF = 0x3f3f3f3f;
    	
    	int dis[][] = new int[n][n];
    	for (int i = 0; i < n; ++i)
    		for (int j = 0; j < n; ++j)
    			dis[i][j] = i != j ? INF : 0;
    	
    	for (int u, v, i = 0; i < m; ++i)
    	{
    		u = nextInt();
    		v = nextInt();
    		--u;
    		--v;
    		dis[u][v] = 1;
    		new Edge(u, v);
    	}
    	
    	for (int k = 0; k < n; ++k)
    		for (int i = 0; i < n; ++i)
    			for (int j = 0; j < n; ++j)
    				dis[i][j] = Math.min(dis[i][j], dis[i][k] + dis[k][j]);

		keyPoint = new ArrayList[n][n];
    	for (int i = 0; i < n; ++i)
    		for (int j = 0; j < n; ++j)
    		{
    			keyPoint[i][j] = new ArrayList<Integer>();
    			if (dis[i][j] >= INF) continue;
    			
    			for (Edge e = first[i]; e != null; e = e.next)
    				if (dis[i][j] == 1 + dis[e.v][j])
    					keyPoint[i][j].add(e.v);
    		}
    	
    	int k = nextInt();
    	
    	@SuppressWarnings("unchecked")
		ArrayList<Integer> stopFrom[] = new ArrayList[n];
    	for (int i = 0; i < n; ++i)
    		stopFrom[i] = new ArrayList<Integer>();
    	
    	for (int s, t, i = 0; i < k; ++i)
    	{
    		s = nextInt();
    		t = nextInt();
    		--s;
    		--t;
    		ban = -1;
    		if (!reach(s, t))
    			continue;
    		int dist = distance(s, t);
    		ArrayList<Integer> keyPoints = new ArrayList<Integer>();
    		for (int j = 0; j < n; ++j)
    		{
    			ban = j;
    			if (!reach(s, t) || distance(s, t) > dist)
    			{
    				stopFrom[j].add(t);
    			}
    		}
    	}
    	
    	dp = new int[n][n];
    	for (int i = 0; i < n; ++i)
    		for (int j = 0; j < n; ++j)
    			dp[i][j] = INF;
    	
    	int change[] = new int[n];
    	for (int i = 0; i < n; ++i)
    		change[i] = INF;
    	
    	change[b] = 0;
    	
    	for (int iter = 0; iter <= n; ++iter)
    	{
    		for (int i = 0; i < n; ++i)
    			for (int next : stopFrom[i])
    				change[i] = Math.min(change[i], dp[i][next] + 1);
    		
    		for (int i = 0; i < n; ++i)
    			for (int j = 0; j < n; ++j)
    				dp[i][j] = Math.min(dp[i][j], change[i]);
/*
        	for (int i = 0; i < n; ++i)
        	{
        		for (int j = 0; j < n; ++j)
        			writer.print(dp[i][j] + " ");
        		writer.println();
        	}
        	
        	writer.println();
        */	
    		memo = new boolean[n][n];
    		for (int i = 0; i < n; ++i)
    			for (int j = 0; j < n; ++j)
    				if (!memo[i][j] && dis[i][j] < INF)
    					go(i, j);

    	}
    	
 //   	for (int it : keyPoint[2][3])
 //   		writer.println(it);
		
    	if (change[a] >= INF)
    		change[a] = -1;
    	
    	writer.println(change[a]);
    }

    private int go(int i, int j) {
		// TODO Auto-generated method stub
		if (i == j) return dp[i][j];
		if (memo[i][j]) return dp[i][j];
		memo[i][j] = true;
		
		int max = 0;
		for (int step : keyPoint[i][j])
			max = Math.max(max, go(step, j));
		dp[i][j] = Math.min(max, dp[i][j]);
		return dp[i][j];			
	}

	public static void main(String[] args) {
        new CF148E().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}