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.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Queue;
import java.util.LinkedList;
import java.util.Collection;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
    private static final int INF = 100000000;
    ArrayList<Integer>[] A;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        int M = in.nextInt();
        int source = in.nextInt();
        int dest = in.nextInt();
        source--; dest--;

        A = new ArrayList[N];
        for (int i = 0; i < N; i++) {
            A[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < M; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            a--; b--;
            A[a].add(b);
        }

        int K = in.nextInt();
        int[] s = new int[K];
        int[] t = new int[K];
        for (int i = 0; i < K; i++) {
            s[i] = in.nextInt();
            t[i] = in.nextInt();
            s[i]--; t[i]--;
        }

        int[][] Dmin = computeAllPaths(N, A);
        ArrayList<Integer>[] B = computeAllSurePaths(N, A, s, t, K, Dmin);

        int[][] Dmax = new int[N][K];
        for (int i = 0; i < N; i++) {
            Arrays.fill(Dmax[i], -1);
        }

        for (int k = 0; k < K; k++) {
            Dmax[dest][k] = 1;
        }

        boolean ok = true;
        while (ok) {
            ok = false;

            for (int c = 0; c < N; c++) {
                for (int k = 0; k < K; k++) {
                    if (Dmin[s[k]][c] + Dmin[c][t[k]] == Dmin[s[k]][t[k]]) {
                        int best = Integer.MAX_VALUE;

                        for (int x : B[c]) {
                            if (x != k) {
                                if (Dmax[c][x] != -1) {
                                    best = Math.min(best, Dmax[c][x] + 1);
                                }
                            }
                        }

                        int worst = -1;
                        boolean allGood = true;
                        for (int x : A[c]) {
                            if (1 + Dmin[x][t[k]] == Dmin[c][t[k]]) {
                                if (Dmax[x][k] == -1) {
                                    allGood = false;
                                    break;
                                }
                                worst = Math.max(worst, Dmax[x][k]);
                            }
                        }

                        if (allGood && worst != -1) {
                            best = Math.min(best, worst);
                        }

                        if (best < Integer.MAX_VALUE) {
                            if (Dmax[c][k] == -1 || best < Dmax[c][k]) {
                                Dmax[c][k] = best;
                                ok = true;
                            }
                        }
                    }
                }
            }
        }

        int ans = Integer.MAX_VALUE;
        for (int k : B[source]) {
            if (Dmax[source][k] != -1) {
                ans = Math.min(ans, Dmax[source][k]);
            }
        }
        if (ans == Integer.MAX_VALUE) {
            ans = -1;
        }
        out.println(ans);
    }

    private ArrayList<Integer>[] computeAllSurePaths(int N, ArrayList<Integer>[] A, int[] s, int[] t, int K, int[][] D) {
        ArrayList<Integer>[] B = new ArrayList[N];
        for (int i = 0; i < N; i++) {
            B[i] = new ArrayList<Integer>();
        }
        for (int bus = 0; bus < K; bus++) {
            computeSurePaths(N, A, s[bus], t[bus], bus, D, B);
        }
        return B;
    }

    private void computeSurePaths(int N, ArrayList<Integer>[] A, int s, int t, int bus, int[][] D, ArrayList<Integer>[] B) {
        int[] cnt = new int[N + 1];
        for (int i = 0; i < N; i++) {
            if (D[s][i] + D[i][t] == D[s][t] && D[s][i] < INF && D[i][t] < INF) {
                cnt[ D[s][i] ]++;
            }
        }
        for (int i = 0; i < N; i++) {
            if (D[s][i] + D[i][t] == D[s][t] && D[s][i] < INF && D[i][t] < INF) {
                if (cnt[ D[s][i] ] == 1) {
                    B[i].add(bus);
                }
            }
        }
    }


    private int[][] computeAllPaths(int N, ArrayList<Integer>[] A) {
        int[][] D = new int[N][];
        for (int start = 0; start < N; start++) {
            D[start] = computePaths(start, N, A);
        }
        return D;
    }

    private int[] computePaths(int start, int N, ArrayList<Integer>[] A) {
        int[] D = new int[N];
        Arrays.fill(D, INF);
        Queue<Integer> Q = new LinkedList<Integer>();
        boolean[] v = new boolean[N];

        D[start] = 0;
        v[start] = true;
        Q.add(start);

        while (!Q.isEmpty()) {
            int p = Q.remove();
            for (int x : A[p]) {
                if (!v[x]) {
                    D[x] = D[p] + 1;
                    v[x] = true;
                    Q.add(x);
                }
            }
        }

        return D;
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));

        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

}