#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
using namespace std;
const long long N = 200, OO = 1e9 + 7, T = 1e6 + 10, mod = 1e9 + 7, P = 6151,
                SQ = 280, lg = 70;
long long dis[N], s[N], t[N], dp[N][N], dk[N];
vector<long long> v[N][N], nxt[N][N];
bool is[N];
int32_t main() {
  long long n, m, a, b;
  cin >> n >> m >> a >> b;
  memset(dp, 63, sizeof(dp));
  memset(dis, 63, sizeof(dis));
  long long MX = dis[0];
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    dp[x][y] = 1;
  }
  for (long long i = 1; i <= n; i++) dp[i][i] = 0;
  for (long long k = 1; k <= n; k++)
    for (long long i = 1; i <= n; i++)
      for (long long j = 1; j <= n; j++)
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  long long q;
  cin >> q;
  for (long long i = 1; i <= q; i++) {
    cin >> s[i] >> t[i];
    if (dp[s[i]][t[i]] == MX) {
      is[i] = true;
      continue;
    }
    for (long long j = 1; j <= n; j++)
      if (dp[s[i]][t[i]] == dp[s[i]][j] + dp[j][t[i]])
        v[i][dp[s[i]][j]].push_back(j);
    for (long long j = 0; j < dp[s[i]][t[i]]; j++) {
      for (auto u : v[i][j])
        for (auto g : v[i][j + 1])
          if (dp[u][g] == 1) nxt[i][u].push_back(g);
    }
  }
  dis[b] = 0;
  for (long long per = 0; per < n; per++) {
    for (long long i = 1; i <= q; i++) {
      if (is[i]) continue;
      for (long long j = 1; j <= n; j++) dk[j] = 0;
      dk[t[i]] = dis[t[i]];
      for (long long j = dp[s[i]][t[i]] - 1; j >= 0; j--) {
        for (auto u : v[i][j]) {
          for (auto g : nxt[i][u]) dk[u] = max(dk[u], dk[g]);
          dk[u] = min(dk[u], dis[u]);
        }
        if (v[i][j].size() != 1) continue;
        dis[v[i][j].back()] = min(dis[v[i][j].back()], dk[v[i][j].back()] + 1);
      }
    }
  }
  if (dis[a] == MX) return cout << -1, 0;
  cout << dis[a] << endl;
  return 0;
}
