#include <bits/stdc++.h>
using namespace std;
const int maxN = 105;
const int maxM = maxN * maxN;
const int INF = 0x3f3f3f3f;
int a[maxN][maxN];
int b[maxN][maxN];
int c[maxN][maxN];
int s[maxN];
int t[maxN];
int ans[maxN];
int g[maxN], f[maxN];
int N, M, S, T;
int cnt;
int dfs(int x, int y) {
  if (g[x] == cnt) return f[x];
  g[x] = cnt;
  int Ans = -1;
  for (int i = 1; i <= N; i++)
    if (a[x][i] == 1 && a[x][i] + a[i][y] == a[x][y]) Ans = max(Ans, dfs(i, y));
  if (Ans < 0) Ans = a[0][0];
  return f[x] = min(Ans, ans[x] + 1);
}
int main() {
  scanf("%d%d%d%d", &N, &M, &S, &T);
  memset(a, INF, sizeof(a));
  for (int i = 1; i <= N; i++) a[i][i] = 0;
  for (int i = 1; i <= M; i++) {
    int u, v;
    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", &M);
  for (int i = 1; i <= M; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    for (int j = 1; j <= N; j++)
      if (a[x][j] != INF && a[x][j] + a[j][y] == a[x][y]) b[i][a[x][j]]++;
    for (int j = 1; j <= N; j++)
      if (a[x][j] != INF && a[x][j] + a[j][y] == a[x][y] && b[i][a[x][j]] == 1)
        c[i][j] = 1;
    s[i] = x;
    t[i] = y;
  }
  memset(ans, INF, sizeof(ans));
  ans[T] = 0;
  for (;;) {
    bool flag = false;
    for (int i = 1; i <= M; i++) {
      for (int j = 1; j <= N; j++) {
        if (c[i][j]) {
          ++cnt;
          int tmp = dfs(j, t[i]);
          if (tmp < ans[j]) ans[j] = tmp, flag = true;
        }
      }
    }
    if (flag == false) break;
  }
  printf("%d\n", ans[S] != INF ? ans[S] : -1);
  return 0;
}
