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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void upmax(T& a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void upmin(T& a, T b) {
  if (a > b) a = b;
}
const int maxn = 103;
const int maxm = 200007;
const int mod = 1000000007;
const int inf = 0x7fffffff;
const double eps = 1e-7;
typedef int arr[maxn];
typedef int adj[maxm];
inline int fcmp(double a, double b) {
  if (fabs(a - b) <= eps) return 0;
  if (a < b - eps) return -1;
  return 1;
}
inline int add(int a, int b) { return ((long long)a + b) % mod; }
inline int mul(int a, int b) { return ((long long)a * b) % mod; }
inline int dec(int a, int b) { return add(a, mod - b % mod); }
inline int Pow(int a, int b) {
  int t = 1;
  while (b) {
    if (b & 1) t = mul(t, a);
    a = mul(a, a), b >>= 1;
  }
  return t;
}
template <typename Type>
inline Type RD() {
  char c = getchar();
  Type x = 0, flag = 1;
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    flag = -1;
  else
    x = c - '0';
  while (isdigit(c = getchar())) x = x * 10 + c - '0';
  return x * flag;
}
inline char rdch() {
  char c = getchar();
  while (!isalpha(c)) c = getchar();
  return c;
}
int n, m, a, b, k;
arr f[maxn], g[maxn], s, t;
void input() {
  n = RD<int>(), m = RD<int>(), a = RD<int>(), b = RD<int>();
  for (int i = 1, _ = n; i <= _; i++)
    for (int j = 1, _ = n; j <= _; j++)
      if (i != j) f[i][j] = m + 1;
  for (int i = 1, _ = m; i <= _; i++) {
    int u = RD<int>(), v = RD<int>();
    f[u][v] = g[u][v] = 1;
  }
  k = RD<int>();
  for (int i = 1, _ = k; i <= _; i++) s[i] = RD<int>(), t[i] = RD<int>();
}
inline void floyd() {
  for (int k = 1, _ = n; k <= _; k++)
    for (int i = 1, _ = n; i <= _; i++)
      for (int j = 1, _ = n; j <= _; j++)
        if (i != j) {
          int w1 = f[i][k] + f[k][j], w2 = g[i][k] * g[k][j];
          if (f[i][j] > w1)
            f[i][j] = w1, g[i][j] = w2;
          else if (f[i][j] == w1)
            g[i][j] += w2;
        }
}
arr good, mark[maxn];
inline void expand(int cur, int k) {
  static queue<int> Q;
  static arr vis;
  int s = ::s[k], t = ::t[k];
  int dis = f[s][t], tot = g[s][t];
  if (dis > m) return;
  Q.push(t);
  for (int i = 1, _ = n; i <= _; i++) good[i] = 1;
  good[t] = 0;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    vis[u] = 0;
    if (good[u] && (u == s || g[s][u] * g[u][t] == tot)) mark[cur][u] = 1;
    good[u] |= mark[cur - 1][u];
    for (int v = 1, _ = n; v <= _; v++)
      if (f[v][u] == 1 && f[s][v] + 1 + f[u][t] == dis) {
        good[v] &= good[u];
        if (!vis[v]) Q.push(v), vis[v] = 1;
      }
  }
}
void solve() {
  floyd();
  mark[0][b] = 1;
  for (int cur = 1, _ = n; cur <= _; cur++) {
    for (int i = 1, _ = n; i <= _; i++) mark[cur][i] = mark[cur - 1][i];
    for (int i = 1, _ = k; i <= _; i++) expand(cur, i);
    if (mark[cur][a]) return (void)(printf("%d\n", cur));
  }
  puts("-1");
}
int main() {
  input();
  solve();
  return 0;
}