#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 5;
const int inf = 1e9;
int f[N][N], n, m, A, B, nb;
int S[N], T[N];
vector<int> pss[N][N];
int res[N], t[N];
void relax(int &a, int b) {
  if (a < b) a = b;
}
void upd(int &a, int b) {
  if (a > b) a = b;
}
void floyd() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (f[i][j] == 0 && i != j) f[i][j] = inf;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (i != j) upd(f[i][j], f[i][k] + f[k][j]);
}
int main() {
  scanf("%d%d%d%d", &n, &m, &A, &B);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    f[a][b] = 1;
  }
  floyd();
  for (int i = 1; i <= n; i++) res[i] = inf;
  scanf("%d", &nb);
  for (int i = 1; i <= nb; i++) scanf("%d%d", &S[i], &T[i]);
  for (int i = 1; i <= nb; i++) {
    if (f[S[i]][T[i]] == inf) continue;
    for (int j = 1; j <= n; j++)
      if (f[S[i]][j] + f[j][T[i]] == f[S[i]][T[i]])
        pss[i][f[S[i]][j]].push_back(j);
  }
  res[B] = 0;
  int updd = 1;
  int tim = 0;
  while (updd) {
    tim++;
    updd = 0;
    for (int i = 1; i <= nb; i++) {
      if (f[S[i]][T[i]] == inf) continue;
      for (int j = 1; j <= n; j++) t[i] = 0;
      t[T[i]] = res[T[i]];
      for (int len = f[S[i]][T[i]] - 1; len >= 0; len--) {
        for (vector<int>::iterator ii = pss[i][len].begin();
             ii != pss[i][len].end(); ii++) {
          t[*ii] = 0;
          for (vector<int>::iterator jj = pss[i][len + 1].begin();
               jj != pss[i][len + 1].end(); jj++)
            if (f[*ii][*jj] == 1) relax(t[*ii], t[*jj]);
          upd(t[*ii], res[*ii]);
        }
        if (pss[i][len].size() == 1) {
          int u = pss[i][len][0];
          if (res[u] == inf && t[u] < tim) {
            res[u] = tim;
            updd = 1;
          }
        }
      }
    }
  }
  printf("%d\n", res[A] == inf ? -1 : res[A]);
  return 0;
}
