#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
int n, m, A, B, T, U[maxn], V[maxn];
int dis[maxn][maxn], pass[maxn][maxn];
int g[maxn], f[maxn];
bool vis[maxn];
bool OnRoad(int S, int x, int T) { return dis[S][x] + dis[x][T] == dis[S][T]; }
int dfs(int u, int T) {
  if (u == T) return f[u];
  if (vis[u] == 1) return g[u];
  vis[u] = 1;
  g[u] = 0;
  for (int i = 1; i <= n; i++) {
    if (OnRoad(u, i, T) && dis[u][T] == dis[i][T] + 1)
      g[u] = max(g[u], dfs(i, T));
  }
  return g[u] = min(g[u], f[u]);
}
void floyd() {
  int i, j, k;
  for (k = 1; k <= n; k++)
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++)
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
}
int main() {
  int i, j, k;
  scanf("%d%d%d%d", &n, &m, &A, &B);
  for (i = 0; i <= n; i++)
    for (j = 0; j <= n; j++) dis[i][j] = 1000000000;
  for (i = 1; i <= n; i++) dis[i][i] = 0;
  for (i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    dis[u][v] = 1;
  }
  floyd();
  scanf("%d", &T);
  for (k = 1; k <= T; k++) {
    scanf("%d%d", &U[k], &V[k]);
    int S = U[k], T = V[k];
    if (dis[S][T] == 1000000000) continue;
    for (i = 1; i <= n; i++)
      if (OnRoad(S, i, T)) {
        bool flag = 1;
        for (j = 1; j <= n && flag; j++) {
          if (i == j) continue;
          if (OnRoad(S, j, T) && dis[S][j] == dis[S][i]) flag = 0;
        }
        if (flag) pass[k][i] = 1;
      }
  }
  for (i = 0; i <= n; i++) f[i] = 1000000000;
  f[B] = 0;
  while (1) {
    bool gono = 0;
    for (i = 1; i <= T; i++) {
      if (dis[U[i]][V[i]] == 1000000000) continue;
      memset(vis, 0, sizeof(vis));
      memset(g, 0, sizeof(g));
      for (j = 1; j <= n; j++)
        if (pass[i][j]) {
          int tmp = dfs(j, V[i]) + 1;
          if (tmp < f[j]) f[j] = tmp, gono = 1;
        }
    }
    if (!gono) break;
  }
  int Aang = f[A];
  if (Aang >= 1000000000) Aang = -1;
  printf("%d\n", Aang);
}
