#include <bits/stdc++.h>
int may[110][110][110];
int dis[110][110];
int app[110][110];
int n, m, a, b, k;
int s[110], t[110];
int cost[110][110], cnt[110][110];
int q1[10010], q2[10010], head, tail;
int h[110];
bool done() {
  int i, j, s, val, flag = 0;
  for (i = 1; i <= k; ++i)
    for (j = 1; j <= n; ++j) {
      for (s = 1; s <= k; ++s)
        if (app[s][j] && cost[s][j] + 1 < cost[i][j]) {
          cost[i][j] = cost[s][j] + 1;
          flag = 1;
        }
      val = -1;
      for (s = 1; s <= n; ++s)
        if (may[i][j][s] && cost[i][s] > val) val = cost[i][s];
      if (val != -1 && val < cost[i][j]) {
        cost[i][j] = val;
        flag = 1;
      }
    }
  return flag;
}
void make(int num, int ss, int tt) {
  int i;
  memset(h, 0, sizeof(h));
  for (i = 1; i <= n; ++i)
    if (dis[ss][i] + dis[i][tt] == dis[ss][tt]) {
      if (h[dis[ss][i]] == 0)
        h[dis[ss][i]] = i;
      else
        h[dis[ss][i]] = -1;
    }
  for (i = 0; i <= dis[ss][tt]; ++i)
    if (h[i] > 0) app[num][h[i]] = 1;
}
int main() {
  int i, j, u, v, p;
  scanf("%d%d%d%d", &n, &m, &a, &b);
  memset(dis, 60, sizeof(dis));
  memset(cost, 60, sizeof(cost));
  for (i = 1; i <= n; ++i) dis[i][i] = 0;
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    dis[u][v] = 1;
  }
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j)
      for (p = 1; p <= n; ++p)
        if (dis[j][p] > dis[j][i] + dis[i][p])
          dis[j][p] = dis[j][i] + dis[i][p];
  scanf("%d", &k);
  for (i = 1; i <= k; ++i) {
    scanf("%d%d", s + i, t + i);
    if (dis[s[i]][t[i]] <= 1000) make(i, s[i], t[i]);
    for (u = 1; u <= n; ++u)
      if (dis[s[i]][t[i]] == dis[s[i]][u] + dis[u][t[i]]) {
        for (v = 1; v <= n; ++v)
          if (dis[u][v] == 1 &&
              dis[s[i]][u] + dis[v][t[i]] + 1 == dis[s[i]][t[i]]) {
            may[i][u][v] = 1;
            ++cnt[i][u];
          }
      }
  }
  for (i = 1; i <= k; ++i)
    if (app[i][b]) cost[i][b] = 0;
  while (done())
    ;
  p = 1000000;
  for (i = 1; i <= k; ++i)
    if (app[i][a] && cost[i][a] < p) p = cost[i][a];
  if (p <= 1000)
    printf("%d\n", p + 1);
  else
    puts("-1");
  return 0;
}
