#include <bits/stdc++.h>
using namespace std;
const int N = 101;
const int I = 1 << 28;
int d[N][N], cnt[N][N], s[N], t[N], lev[N], ans[N], z[N], cur, n, m, a, b, w;
bool c[N][N];
int BFS(int v, int u) {
  if (lev[v] == cur) return ans[v];
  lev[v] = cur;
  int res = -1;
  for (int i = 1; i <= n; i++)
    if (d[v][i] == 1 && 1 + d[i][u] == d[v][u]) res = max(res, BFS(i, u));
  res = (res < 0 ? z[0] : res);
  ans[v] = min(res, z[v] + 1);
  return ans[v];
}
int main() {
  scanf("%d%d%d%d", &n, &m, &a, &b);
  memset(d, 63, sizeof d);
  memset(z, 63, sizeof z);
  for (int i = 1; i <= n; i++) d[i][i] = 0;
  for (int i = 1, v, u; i <= m; i++) {
    scanf("%d%d", &v, &u);
    d[v][u] = 1;
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  scanf("%d", &w);
  for (int i = 1; i <= w; i++) {
    scanf("%d%d", &s[i], &t[i]);
    for (int j = 1; j <= n; j++)
      if (d[s[i]][j] < I)
        cnt[i][d[s[i]][j]] += (d[s[i]][j] + d[j][t[i]] == d[s[i]][t[i]]);
    for (int j = 1; j <= n; j++)
      c[i][j] = (d[s[i]][j] < I && d[s[i]][j] + d[j][t[i]] == d[s[i]][t[i]] &&
                 cnt[i][d[s[i]][j]] == 1);
  }
  z[b] = 0;
  bool F = true;
  for (;;) {
    F = false;
    for (int i = 1; i <= w; i++) {
      for (int j = 1; j <= n; j++) {
        if (!c[i][j]) continue;
        cur++;
        int res = BFS(j, t[i]);
        F |= (res < z[j]);
        z[j] = min(z[j], res);
      }
    }
    if (!F) break;
  }
  z[a] = (z[a] < I ? z[a] : -1);
  printf("%d", z[a]);
}
