#include <bits/stdc++.h>
using namespace std;
const int N = 109;
const int INF = 0x3f3f3f3f;
int m, n, a, b;
int dis[N][N];
int sv[N], tv[N], s, t;
vector<int> to[N];
bool reachable[N], tmp[N];
bool dfs(int now) {
  if (reachable[now]) {
    return true;
  }
  if (now == t) {
    return false;
  }
  int siz = to[now].size();
  for (int i = 0; i < siz; i++) {
    if (dis[s][now] + 1 == dis[s][to[now][i]] &&
        dis[s][t] == dis[s][to[now][i]] + dis[to[now][i]][t]) {
      if (!dfs(to[now][i])) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  scanf("%d %d %d %d", &n, &m, &a, &b);
  memset(dis, 0x3f, sizeof(dis));
  memset(reachable, false, sizeof(reachable));
  reachable[b] = true;
  for (int i = 1; i <= n; i++) {
    dis[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    to[u].push_back(v);
    dis[u][v] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        dis[j][k] = min(dis[j][k], dis[j][i] + dis[i][k]);
      }
    }
  }
  int k;
  scanf("%d", &k);
  for (int i = 0; i < k; i++) {
    scanf("%d %d", &sv[i], &tv[i]);
  }
  int ans;
  memcpy(tmp, reachable, sizeof(tmp));
  for (ans = 1; ans <= n; ans++) {
    for (int i = 0; i < k; i++) {
      s = sv[i], t = tv[i];
      if (dis[s][t] == INF) {
        continue;
      }
      for (int j = 1; j <= n; j++) {
        if (dis[s][t] == dis[s][j] + dis[j][t]) {
          bool fail = false;
          for (int l = 1; l <= n; l++) {
            if (l != j && dis[s][t] == dis[s][l] + dis[l][t] &&
                dis[s][l] == dis[s][j]) {
              fail = true;
            }
          }
          if (!fail) {
            if (dfs(j)) {
              tmp[j] = true;
            }
          }
        }
      }
    }
    memcpy(reachable, tmp, sizeof(tmp));
    if (reachable[a]) {
      break;
    }
  }
  if (ans > n) {
    ans = -1;
  }
  printf("%d\n", ans);
  return 0;
}
