#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
const long long maxn = 1e2 + 10, maxm = 1e5 + 10, lg = 20, mod = 1e9 + 7,
                inf = 1e18;
long long n, m, a, b, K, dp[maxn], pd[maxn];
vector<pair<long long, long long> > bus;
long long g[maxn][maxn];
vector<long long> h[maxn];
bool rr[maxn][maxn];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> a >> b;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) g[i][j] = inf, g[i][i] = 0;
  while (m--) {
    long long v, u;
    cin >> v >> u;
    g[v][u] = rr[v][u] = 1;
  }
  for (int k = 1; k <= n; k++)
    for (int v = 1; v <= n; v++)
      for (int u = 1; u <= n; u++) g[v][u] = min(g[v][u], g[v][k] + g[k][u]);
  cin >> K;
  while (K--) {
    long long ss, tt;
    cin >> ss >> tt;
    if (g[ss][tt] < inf) bus.push_back({ss, tt});
  }
  memset(dp, 69, sizeof(dp));
  dp[b] = 0;
  for (int k = 1; k <= n; k++)
    for (auto x : bus) {
      memset(pd, 69, sizeof(pd));
      for (int i = 0; i <= g[x.first][x.second]; i++) h[i].clear();
      for (int i = 1; i <= n; i++)
        if (g[x.first][i] + g[i][x.second] == g[x.first][x.second])
          h[g[x.first][i]].push_back(i);
      pd[x.second] = dp[x.second];
      for (int i = g[x.first][x.second] - 1; i >= 0; i--) {
        for (auto v : h[i]) {
          pd[v] = -1;
          for (auto u : h[i + 1])
            if (rr[v][u]) pd[v] = max(pd[v], pd[u]);
          if (pd[v] == -1) pd[v] = inf;
          pd[v] = min(pd[v], dp[v]);
        }
        if ((long long)(h[i].size()) == 1)
          dp[h[i][0]] = min(dp[h[i][0]], pd[h[i][0]] + 1);
      }
    }
  cout << (dp[a] >= inf ? -1 : dp[a]);
  return 0;
}
