#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
const long long MAXN = 1e2 + 10, INF = 1e9;
long long n, m, k, a, b, u, v, floyd[MAXN][MAXN], second[MAXN], t[MAXN],
    dp[2][MAXN];
bool bo[MAXN][MAXN];
vector<long long> h[MAXN];
void update(long long id) {
  if (floyd[second[id]][t[id]] == INF) return;
  for (long long i = 0; i <= floyd[second[id]][t[id]]; i++) h[i].clear();
  for (long long i = 1; i <= n; i++) dp[1][i] = INF;
  for (long long i = 1; i <= n; i++)
    if (floyd[second[id]][i] + floyd[i][t[id]] == floyd[second[id]][t[id]])
      h[floyd[second[id]][i]].push_back(i);
  dp[1][t[id]] = dp[0][t[id]];
  for (long long i = floyd[second[id]][t[id]] - 1; i >= 0; i--) {
    for (auto u : h[i]) {
      dp[1][u] = -1;
      for (auto v : h[i + 1])
        if (bo[u][v]) dp[1][u] = max(dp[1][u], dp[1][v]);
      if (dp[1][u] == -1)
        dp[1][u] = dp[0][u];
      else
        dp[1][u] = min(dp[1][u], dp[0][u]);
    }
    if ((long long)h[i].size() == 1)
      dp[0][h[i][0]] = min(dp[0][h[i][0]], dp[1][h[i][0]] + 1);
  }
  return;
}
void pre_Floyd() {
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++) floyd[i][j] = INF, floyd[j][j] = 0;
  return;
}
void Floyd_update() {
  for (long long k = 1; k <= n; k++)
    for (long long i = 1; i <= n; i++)
      for (long long j = 1; j <= n; j++)
        floyd[i][j] = min(floyd[i][j], floyd[i][k] + floyd[k][j]);
  return;
}
int32_t main() {
  cin >> n >> m >> a >> b, pre_Floyd();
  for (long long i = 1; i <= n; i++) dp[0][i] = INF;
  for (long long i = 1; i <= m; i++)
    cin >> u >> v, floyd[u][v] = 1, bo[u][v] = true;
  cin >> k;
  for (long long i = 1; i <= k; i++) cin >> second[i] >> t[i];
  Floyd_update(), dp[0][b] = 0;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= k; j++) update(j);
  if (dp[0][a] == INF) return cout << -1 << '\n', 0;
  return cout << dp[0][a] << '\n', 0;
}
