#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
const int maxn = 1e2 + 5;
int vis[maxn], NOW, num[maxn];
int dp[maxn], f[maxn][maxn];
int n, m, K, DP[maxn], s[maxn], t[maxn];
bool b[maxn][maxn];
int dfs(int x, int path) {
  if (vis[x] == NOW) return DP[x];
  vis[x] = NOW;
  int tmp = -1;
  for (int y = 1; y <= n; y++)
    if (f[x][y] == 1 && f[x][t[path]] == f[y][t[path]] + 1)
      tmp = max(tmp, dfs(y, path));
  if (tmp == -1) tmp = 1e9;
  if (tmp > dp[x]) tmp = dp[x];
  return DP[x] = tmp;
}
int main() {
  n = read(), m = read(), s[0] = read(), t[0] = read();
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++) f[i][j] = f[j][i] = 1e9;
  for (int i = 1, x, y; i <= m; i++) f[x = read()][y = read()] = 1;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
  K = read();
  for (int i = 1; i <= K; i++) {
    s[i] = read(), t[i] = read();
    if (f[s[i]][t[i]] == 1e9) continue;
    for (int j = 1; j <= n; j++) {
      if (f[s[i]][j] + f[j][t[i]] == f[s[i]][t[i]]) num[f[s[i]][j]]++;
    }
    for (int j = 1; j <= n; j++)
      if (f[s[i]][j] + f[j][t[i]] == f[s[i]][t[i]]) {
        if (num[f[s[i]][j]] == 1) b[i][j] = 1;
        num[f[s[i]][j]] = 0;
      }
  }
  for (int i = 1; i <= n; i++) dp[i] = DP[i] = 1e9;
  dp[t[0]] = 0;
  bool flag = 1;
  while (flag) {
    flag = 0;
    for (int i = 1; i <= K; i++)
      for (int j = 1; j <= n; j++) {
        if (b[i][j]) {
          NOW++;
          int tmp = dfs(j, i) + 1;
          if (tmp < dp[j]) {
            flag = 1;
            dp[j] = tmp;
          }
        }
      }
  }
  if (dp[s[0]] == 1e9) dp[s[0]] = -1;
  cout << dp[s[0]];
  return 0;
}
