#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
template <class T>
inline void read(T& x, T& y) {
  read(x);
  read(y);
}
template <class T>
inline void read(T& x, T& y, T& z) {
  read(x);
  read(y);
  read(z);
}
inline char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
const int N = 111;
const int Q = 1111;
int n, m, q, i, j, k, l, p, s, t;
int a[N][N], tail[Q];
bool must[Q][N];
bool o[N];
int f[N], ans[N];
int dfs(int x, int t) {
  if (x == t) return ans[t];
  if (o[x]) return f[x];
  o[x] = 1;
  f[x] = 0;
  for (int i = (1); i <= (n); i++)
    if (a[x][i] + a[i][t] == a[x][t] && a[x][i] == 1)
      f[x] = max(f[x], dfs(i, t));
  f[x] = min(f[x], ans[x]);
  return f[x];
}
int main() {
  read(n, m);
  read(s, t);
  memset(a, 3, sizeof(a));
  for (i = 1; i <= n; i++) a[i][i] = 0;
  int x, y;
  for (i = 1; i <= m; i++) {
    read(x, y);
    a[x][y] = 1;
  }
  for (k = 1; k <= n; k++)
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
  read(q);
  for (i = 1; i <= q; i++) {
    read(x, y);
    tail[i] = y;
    if (a[x][y] > n) continue;
    for (j = 1; j <= n; j++)
      if (a[x][j] + a[j][y] == a[x][y]) {
        must[i][j] = 1;
        for (k = 1; k <= n; k++)
          if (k != j && a[x][k] == a[x][j] && a[k][y] == a[j][y]) {
            must[i][j] = 0;
            break;
          }
      }
  }
  memset(ans, 3, sizeof(ans));
  ans[t] = 0;
  while (1) {
    bool flag = 0;
    for (i = 1; i <= q; i++) {
      memset(o, 0, sizeof(o));
      for (j = 1; j <= n; j++)
        if (must[i][j]) {
          int tt = dfs(j, tail[i]) + 1;
          if (tt < ans[j]) ans[j] = tt, flag = 1;
        }
    }
    if (!flag) break;
  }
  printf("%d\n", ans[s] > int(1e6) ? -1 : ans[s]);
  scanf("\n");
  return 0;
}
