#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const int N = 1e2 + 5;
const long long mod = 1e9 + 7;
const long long mod2 = 998244353;
const long long inf = 8e18;
const int LOG = 22;
long long pw(long long a, long long b, long long M) {
  return (!b ? 1
             : (b & 1 ? (a * pw(a * a % M, b / 2, M)) % M
                      : pw(a * a % M, b / 2, M)));
}
int n, m, s, t, dis[N][N], ans[N], mark[N], dp[N];
pair<int, int> Q[N];
vector<int> G[N], nodes[N][N];
void bfs(int st) {
  for (int i = 0; i < N; i++) dis[st][i] = 1e6;
  dis[st][st] = 0;
  queue<int> q;
  q.push(st);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto u : G[v]) {
      if (dis[st][u] > dis[st][v] + 1) {
        dis[st][u] = dis[st][v] + 1;
        q.push(u);
      }
    }
  }
}
int main() {
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      if (i != j) dis[i][j] = 1e6;
  scanf("%d%d%d%d", &n, &m, &s, &t);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) bfs(i);
  int T;
  scanf("%d", &T);
  for (int _ = 1; _ <= T; _++) {
    int v, u;
    scanf("%d%d", &v, &u);
    Q[_] = make_pair(v, u);
    for (int i = 1; i <= n; i++) {
      if (dis[v][i] + dis[i][u] == dis[v][u] && dis[v][u] < 1e6) {
        nodes[_][dis[v][i]].push_back(i);
      }
    }
  }
  queue<int> q;
  q.push(t);
  for (int i = 0; i < N; i++) dp[i] = ans[i] = 1e6;
  ans[t] = 0;
  while (!q.empty()) {
    int cur = q.front();
    mark[cur] = 1;
    q.pop();
    int nxt = 0, mn = 2e6;
    for (int i = 1; i <= T; i++) {
      for (int D = n; ~D; D--) {
        for (auto v : nodes[i][D]) {
          int Mx = -1, seen = 0;
          for (auto u : G[v]) {
            if (dis[Q[i].first][v] + 1 + dis[u][Q[i].second] ==
                    dis[Q[i].first][Q[i].second] &&
                dis[Q[i].first][Q[i].second] < 1e6) {
              Mx = max(Mx, dp[u]);
              seen = 1;
            }
          }
          if (!seen) Mx = 1e6;
          dp[v] = min(ans[v], Mx);
          if (mark[v]) continue;
          if ((int)nodes[i][D].size() > 1) continue;
          if (dp[v] < mn) {
            nxt = v;
            mn = dp[v] + 1;
          }
        }
      }
    }
    if (mn < 2e6) {
      q.push(nxt);
      ans[nxt] = mn;
    }
  }
  if (ans[s] >= 1e6) ans[s] = -1;
  printf("%d\n", ans[s]);
  return 0;
}
