#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool updmn(T& A, const T& B) {
  return A > B ? A = B, 1 : 0;
}
template <typename T>
bool updmx(T& A, const T& B) {
  return A < B ? A = B, 1 : 0;
}
const int INF = 0x3f3f3f3f;
const int maxn = 110;
const int maxb = 110;
int n, m, S, T;
int G[maxn][maxn];
int from[maxb], to[maxb];
vector<int> step[maxb][maxn];
int f[maxn], t[maxn];
void solve() {
  scanf("%d%d%d%d", &n, &m, &S, &T);
  memset(G, 0x3f, sizeof G);
  for (int i = (1); i <= (n); ++i) G[i][i] = 0;
  for (int i = (1); i <= (m); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u][v] = 1;
  }
  scanf("%d", &m);
  for (int p = (1); p <= (m); ++p) scanf("%d%d", &from[p], &to[p]);
  for (int k = (1); k <= (n); ++k)
    for (int i = (1); i <= (n); ++i)
      for (int j = (1); j <= (n); ++j) updmn(G[i][j], G[i][k] + G[k][j]);
  for (int p = (1); p <= (m); ++p) {
    int i = from[p], j = to[p];
    if (G[i][j] >= INF) continue;
    for (int o = (0); o <= (G[i][j]); ++o) step[p][o].clear();
    for (int k = (1); k <= (n); ++k)
      if (G[i][j] == G[i][k] + G[k][j]) step[p][G[i][k]].push_back(k);
  }
  memset(f, 0x3f, sizeof f);
  f[T] = 0;
  for (int d = 1;; ++d) {
    bool fg = 0;
    for (int p = (1); p <= (m); ++p) {
      int i = from[p], j = to[p];
      if (G[i][j] >= INF) continue;
      t[j] = f[j];
      for (int o = G[i][j] - 1; o >= 0; --o) {
        for (vector<int>::iterator u = step[p][o].begin();
             u != step[p][o].end(); ++u) {
          t[*u] = 0;
          for (vector<int>::iterator v = step[p][o + 1].begin();
               v != step[p][o + 1].end(); ++v)
            if (G[*u][*v] == 1) updmx(t[*u], t[*v]);
          updmn(t[*u], f[*u]);
        }
        if (step[p][o].size() == 1) {
          int u = step[p][o][0];
          if (f[u] >= INF && t[u] < d) {
            f[u] = d;
            fg = 1;
          }
        }
      }
    }
    if (!fg) break;
  }
  printf("%d\n", f[S] >= INF ? -1 : f[S]);
}
int main() {
  solve();
  return 0;
}
