#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, dist[111][111], from[111], to[111], ans, f[111], g[111], t;
bool can[111][111], visit[111];
inline int dfs(int x, int aim) {
  if (x == aim) return f[x];
  if (visit[x] == true) return g[x];
  visit[x] = true;
  g[x] = 0;
  for (int i = 1; i <= n; i++)
    if (dist[x][i] + dist[i][aim] == dist[x][aim] &&
        dist[x][aim] == dist[i][aim] + 1)
      g[x] = max(g[x], dfs(i, aim));
  return g[x] = min(g[x], f[x]);
}
int main() {
  scanf("%d%d%d%d", &n, &m, &a, &b);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) dist[i][j] = ~0U >> 2;
  for (int i = 1; i <= n; i++) dist[i][i] = 0;
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d%d", &u, &v);
    dist[u][v] = 1;
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (dist[i][j] > dist[i][k] + dist[k][j])
          dist[i][j] = dist[i][k] + dist[k][j];
  scanf("%d", &t);
  for (int k = 1; k <= t; k++) {
    scanf("%d%d", &from[k], &to[k]);
    int S = from[k], T = to[k];
    if (dist[S][T] == ~0U >> 2) continue;
    for (int i = 1; i <= n; i++) {
      if (dist[S][i] + dist[i][T] == dist[S][T]) {
        bool flag = true;
        for (int j = 1; j <= n && flag; j++) {
          if (j == i) continue;
          if (dist[S][j] + dist[j][T] == dist[S][T])
            if (dist[S][i] == dist[S][j]) flag = false;
        }
        if (flag) can[k][i] = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) f[i] = ~0U >> 2;
  f[b] = 0;
  while (1) {
    bool ff = false;
    for (int i = 1; i <= t; i++) {
      if (dist[from[i]][to[i]] == ~0U >> 2) continue;
      memset(visit, 0, sizeof(visit));
      for (int j = 1; j <= n; j++) {
        if (can[i][j]) {
          int temp = dfs(j, to[i]) + 1;
          if (temp < f[j]) {
            f[j] = temp;
            ff = true;
          }
        }
      }
    }
    if (ff == false) break;
  }
  int ans = f[a];
  if (ans >= ~0U >> 2) ans = -1;
  printf("%d\n", ans);
  return 0;
}
