#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
const int INF = 1 << 25;
int n, m, s, t, T, dis[maxn][maxn], Dp[maxn], dp[maxn];
int A[maxn], B[maxn], cnt, vis[maxn], ss[maxn * 2];
bool b[maxn][maxn];
int dfs(int u, int k) {
  if (vis[u] == cnt) return Dp[u];
  int tmp = -1;
  vis[u] = cnt;
  for (int v = 1; v <= n; v++)
    if (dis[u][v] == 1 && dis[u][B[k]] == dis[v][B[k]] + 1)
      tmp = max(tmp, dfs(v, k));
  if (tmp == -1) tmp = INF;
  tmp = min(tmp, dp[u]);
  return Dp[u] = tmp;
}
int main() {
  scanf("%d %d %d %d", &n, &m, &s, &t);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) dis[i][j] = INF;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    dis[x][y] = 1;
  }
  for (int i = 1; i <= n; i++) dis[i][i] = 0;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
  scanf("%d", &T);
  for (int ii = 1; ii <= T; ii++) {
    int u, v;
    scanf("%d %d", &u, &v);
    A[ii] = u;
    B[ii] = v;
    if (dis[u][v] == INF) continue;
    for (int i = 1; i <= n; i++)
      if (dis[u][i] + dis[i][v] == dis[u][v]) ss[dis[u][i]]++;
    for (int i = 1; i <= n; i++)
      if (dis[u][i] + dis[i][v] == dis[u][v]) {
        if (ss[dis[u][i]] == 1) b[ii][i] = 1;
        ss[dis[u][i]] = 0;
      }
  }
  for (int i = 1; i <= n; i++) dp[i] = Dp[i] = INF;
  dp[t] = 0;
  bool F = 1;
  while (F) {
    F = 0;
    for (int i = 1; i <= T; i++)
      for (int j = 1; j <= n; j++)
        if (b[i][j]) {
          cnt++;
          int tmp = dfs(j, i) + 1;
          if (tmp < dp[j]) F = 1, dp[j] = tmp;
        }
  }
  if (dp[s] == INF) dp[s] = -1;
  printf("%d\n", dp[s]);
  return 0;
}
