#include <bits/stdc++.h>
using namespace std;
const int inf = 0x03030303;
int n, m, dis[120][120], ans[120], x, y, i, j, k, s, t, q, tail[120], tmp[120],
    f[120];
bool must[120][120], bo[120];
int dfs(int x, int t) {
  if (x == t) return ans[t];
  if (bo[x]) return f[x];
  bo[x] = 1;
  f[x] = 0;
  for (int i = 1; i <= n; ++i)
    if (dis[x][i] + dis[i][t] == dis[x][t] && dis[x][i] == 1)
      f[x] = max(f[x], dfs(i, t));
  f[x] = min(f[x], ans[x]);
  return f[x];
}
int main() {
  scanf("%d%d%d%d", &n, &m, &s, &t);
  memset(dis, 3, sizeof(dis));
  for (i = 1; i <= n; ++i) dis[i][i] = 0;
  for (i = 1; i <= m; ++i) scanf("%d%d", &x, &y), dis[x][y] = 1;
  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]);
  scanf("%d", &q);
  for (i = 1; i <= q; ++i) {
    scanf("%d%d", &x, &y);
    tail[i] = y;
    if (dis[x][y] == inf) continue;
    for (j = 1; j <= n; ++j)
      if (dis[x][j] + dis[j][y] == dis[x][y]) {
        must[i][j] = 1;
        for (k = 1; k <= n; ++k)
          if (k != j && dis[x][k] == dis[x][j] && dis[k][y] == dis[j][y]) {
            must[i][j] = 0;
            break;
          }
      }
  }
  memset(ans, 3, sizeof(ans));
  ans[t] = 0;
  for (;;) {
    bool flag = 1;
    for (i = 1; i <= q; ++i) {
      memset(bo, 0, sizeof(bo));
      for (j = 1; j <= n; ++j)
        if (must[i][j]) {
          int tmp = dfs(j, tail[i]) + 1;
          if (tmp < ans[j]) ans[j] = tmp, flag = 0;
        }
    }
    if (flag) break;
  }
  printf("%d\n", ans[s] == inf ? -1 : ans[s]);
}
