#include <bits/stdc++.h>
using namespace std;
int inf = 1e9;
int dist[111][111];
bool must[111][111];
int ans[111];
int from[111], to[111];
int f[111];
bool vis[111];
int n, m, q, s, t;
int dfs(int x, int y) {
  if (x == y) return ans[y];
  if (vis[x]) return f[x];
  vis[x] = 1;
  f[x] = 0;
  for (int i = 1; i <= n; i++) {
    if (dist[x][i] + dist[i][y] == dist[x][y] && dist[x][i] == 1) {
      f[x] = max(f[x], dfs(i, y));
    }
  }
  f[x] = min(f[x], ans[x]);
  return f[x];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> s >> t;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) dist[i][j] = inf;
  for (int i = 1; i <= n; i++) dist[i][i] = 0;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    dist[x][y] = 1;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> from[i] >> to[i];
    if (dist[from[i]][to[i]] == inf) continue;
    for (int j = 1; j <= n; j++) {
      if (dist[from[i]][j] + dist[j][to[i]] == dist[from[i]][to[i]]) {
        must[i][j] = 1;
        for (int k = 1; k <= n; k++) {
          if (k != j && dist[from[i]][k] == dist[from[i]][j] &&
              dist[k][to[i]] == dist[j][to[i]]) {
            must[i][j] = 0;
            break;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) ans[i] = inf;
  ans[t] = 0;
  while (true) {
    bool f = 1;
    for (int i = 1; i <= q; i++) {
      memset(vis, 0, sizeof(vis));
      for (int j = 1; j <= n; j++) {
        if (must[i][j]) {
          int p = dfs(j, to[i]) + 1;
          if (p < ans[j]) {
            ans[j] = p;
            f = 0;
          }
        }
      }
    }
    if (f) break;
  }
  if (ans[s] == inf) ans[s] = -1;
  printf("%d\n", ans[s]);
  return 0;
}
