#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int f[N][N], ans[N], rp[N], S, T, s[N], t[N], n, m, k, vis[N], cho;
int must[N][N];
int ct[N][N];
int dfs(int x, int y) {
  if (vis[x] == cho) return rp[x];
  vis[x] = cho;
  int res = -1;
  for (int j = (1); j <= (int)n; j++)
    if (f[x][j] == 1 && f[x][j] + f[j][y] == f[x][y]) res = max(res, dfs(j, y));
  if (res < 0) res = ans[0];
  rp[x] = min(ans[x] + 1, res);
  return rp[x];
}
int main() {
  scanf("%d%d%d%d", &n, &m, &S, &T);
  memset(f, 63, sizeof f);
  memset(ans, 63, sizeof ans);
  for (int i = (1); i <= (int)n; i++) f[i][i] = 0;
  for (int i = (1); i <= (int)m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    f[x][y] = 1;
  }
  for (int p = (1); p <= (int)n; p++)
    for (int i = (1); i <= (int)n; i++)
      for (int j = (1); j <= (int)n; j++)
        f[i][j] = min(f[i][p] + f[p][j], f[i][j]);
  scanf("%d", &k);
  for (int i = (1); i <= (int)k; i++) {
    scanf("%d%d", &s[i], &t[i]);
    for (int j = (1); j <= (int)n; j++)
      if (f[s[i]][j] < 1e9 && f[s[i]][j] + f[j][t[i]] == f[s[i]][t[i]])
        ct[i][f[s[i]][j]]++;
    for (int j = (1); j <= (int)n; j++)
      if (f[s[i]][j] < 1e9 && f[s[i]][j] + f[j][t[i]] == f[s[i]][t[i]] &&
          ct[i][f[s[i]][j]] == 1)
        must[i][j] = 1;
  }
  bool is_jabby_god = 1;
  ans[T] = 0;
  while (is_jabby_god) {
    bool flag = 0;
    for (int i = (1); i <= (int)k; i++)
      for (int j = (1); j <= (int)n; j++)
        if (must[i][j]) {
          ++cho;
          int tmp = dfs(j, t[i]);
          if (tmp < ans[j]) {
            ans[j] = tmp;
            flag = 1;
          }
        }
    if (!flag) break;
  }
  if (ans[S] < 1e9)
    printf("%d\n", ans[S]);
  else
    printf("-1\n");
  return 0;
}
