#include <bits/stdc++.h>
using namespace std;
const int maxn = 201;
int n, m, num, cnt;
int a[maxn][maxn], b[maxn][maxn], S[maxn], T[maxn];
int ans[maxn], vis[maxn], dp[maxn], p[maxn][maxn];
int dfs(int u, int v) {
  if (vis[u] == cnt) return dp[u];
  vis[u] = cnt;
  int Ans = -1;
  for (int i = 1; i <= n; i++)
    if (a[u][i] == 1 && a[u][i] + a[i][v] == a[u][v]) Ans = max(Ans, dfs(i, v));
  if (Ans < 0) Ans = 1e9;
  dp[u] = min(Ans, ans[u] + 1);
  return dp[u];
}
int main() {
  int u, v;
  scanf("%d%d%d%d", &n, &m, &S[0], &T[0]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j) a[i][j] = 1e9;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    a[u][v] = 1;
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
  scanf("%d", &num);
  for (int i = 1; i <= num; i++) {
    scanf("%d%d", &u, &v);
    for (int j = 1; j <= n; j++)
      if (a[u][j] < 1e9 && a[u][j] + a[j][v] == a[u][v]) b[i][a[u][j]]++;
    for (int j = 1; j <= n; j++)
      if (a[u][j] < 1e9 && a[u][j] + a[j][v] == a[u][v] && b[i][a[u][j]] == 1)
        p[i][j] = 1;
    S[i] = u, T[i] = v;
  }
  for (int i = 1; i <= n; i++) ans[i] = 1e9;
  ans[T[0]] = 0;
  while (1) {
    bool find = 0;
    for (int i = 1; i <= num; i++)
      for (int j = 1; j <= n; j++)
        if (p[i][j]) {
          ++cnt;
          int tmp = dfs(j, T[i]);
          if (tmp < ans[j]) {
            ans[j] = tmp;
            find = 1;
          }
        }
    if (!find) break;
  }
  if (ans[S[0]] < 1e9)
    printf("%d\n", ans[S[0]]);
  else
    printf("-1\n");
  return 0;
}
