#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 15;
int n, m, s, t, x, y, k;
int a[maxn][maxn];
int c[maxn][maxn];
int b[maxn][maxn];
int f[maxn];
int ls[maxn];
int xx[maxn], yy[maxn];
int vis[maxn], sum;
int done(int x, int y) {
  if (vis[x] == sum) return ls[x];
  vis[x] = sum;
  int ans = -1;
  for (int i = 1; i <= n; i++)
    if (a[x][i] + a[i][yy[y]] == a[x][yy[y]] && a[x][i] == 1)
      ans = max(ans, done(i, y));
  if (ans == -1) ans = f[0];
  ls[x] = min(ans, f[x] + 1);
  return ls[x];
}
int main() {
  scanf("%d%d%d%d", &n, &m, &s, &t);
  memset(a, 60, sizeof(a));
  for (int i = 1; i <= n; i++) a[i][i] = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    a[x][y] = 1;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++) a[j][k] = min(a[j][k], a[j][i] + a[i][k]);
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d%d", &x, &y);
    if (a[x][y] == a[0][0]) continue;
    for (int j = 1; j <= n; j++)
      if (a[x][j] + a[j][y] == a[x][y]) b[i][a[x][j]]++;
    for (int j = 1; j <= n; j++)
      if (a[x][j] + a[j][y] == a[x][y] && b[i][a[x][j]] == 1) c[i][j] = 1;
    xx[i] = x;
    yy[i] = y;
  }
  memset(f, 60, sizeof(f));
  f[t] = 0;
  bool boo = true;
  while (boo) {
    boo = false;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= k; j++)
        if (c[j][i] == 1) {
          sum++;
          int anss = done(i, j);
          if (anss < f[i]) f[i] = anss, boo = true;
        }
  }
  if (f[s] < f[0])
    printf("%d\n", f[s]);
  else
    printf("-1\n");
  return 0;
}
