#include <bits/stdc++.h>
using namespace std;
const double pi = acos(0) * 2;
template <class T>
inline T abs1(T a) {
  return a < 0 ? -a : a;
}
template <class T>
inline T max1(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T min1(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline T gcd1(T a, T b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd1(b, a % b);
}
template <class T>
inline T lb(T num) {
  return num & (-num);
}
template <class T>
inline int bitnum(T num) {
  int ans = 0;
  while (num) {
    num -= lb(num);
    ans++;
  }
  return ans;
}
long long pow(long long n, long long m, long long mod = 0) {
  long long ans = 1;
  long long k = n;
  while (m) {
    if (m & 1) {
      ans *= k;
      if (mod) ans %= mod;
    }
    k *= k;
    if (mod) k %= mod;
    m >>= 1;
  }
  return ans;
}
const int maxn = 200;
const int inf = 100000;
int n, m, from, to, ter, lno;
int head[maxn], tail[maxn];
int mp[maxn][maxn], mpdis[maxn][maxn];
int dis[maxn];
int q[maxn], l, r, dp[maxn][maxn][2];
bool f[maxn], is[maxn][maxn];
int route[maxn][2];
bool fe[maxn * maxn * 2][maxn];
struct edge {
  int to, nxt1, from, nxt2;
} e[maxn * maxn * 2];
int main() {
  scanf("%d%d%d%d", &n, &m, &from, &to);
  from--;
  to--;
  memset(head, -1, sizeof(head));
  memset(tail, -1, sizeof(tail));
  for (int i = 0; i < 200; i++)
    for (int j = 0; j < 200; j++) {
      if (i == j)
        mpdis[i][j] = 0;
      else
        mpdis[i][j] = inf;
    }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    mpdis[a][b] = 1;
    e[i].to = b, e[i].from = a;
    e[i].nxt1 = head[a];
    e[i].nxt2 = tail[b];
    head[a] = i;
    tail[b] = i;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        if (mpdis[j][i] + mpdis[i][k] < mpdis[j][k])
          mpdis[j][k] = mpdis[i][k] + mpdis[j][i];
  int nt;
  scanf("%d", &nt);
  memset(mp, 0, sizeof(mp));
  for (int i1 = 0; i1 < nt; i1++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    route[i1][0] = a;
    route[i1][1] = b;
    if (mpdis[a][b] == inf) continue;
    memset(f, 0, sizeof(f));
    l = 0;
    r = 1;
    q[0] = a;
    f[a] = 1;
    bool ff = 0;
    while (l != r) {
      int num = q[l++];
      if (l == maxn) l = 0;
      f[num] = 0;
      ff = 0;
      if (l == r) ff = 1;
      int stat1 = 0;
      for (int i = head[num]; i != -1; i = e[i].nxt1) {
        if (mpdis[e[i].to][b] != mpdis[num][b] - 1) continue;
        if (!f[e[i].to]) {
          q[r++] = e[i].to;
          if (r == maxn) r = 0;
          f[e[i].to] = 1;
        }
        stat1++;
      }
      dp[i1][num][0] = stat1;
      if (ff) is[i1][num] = 1;
    }
  }
  l = 0;
  r = 1;
  for (int i = 0; i < n; i++) dis[i] = inf;
  dis[to] = 0;
  q[0] = to;
  for (; l != r;) {
    int num = q[l++];
    if (l == maxn) l = 0;
    for (int i = 0; i < nt; i++) {
      int q1[maxn], l1 = 0, r1 = 1;
      q1[0] = num;
      for (; l1 != r1;) {
        int num1 = q1[l1++];
        if (l1 == maxn) l1 = 0;
        for (int j = tail[num1]; j != -1; j = e[j].nxt2) {
          if (fe[j][i]) continue;
          if (mpdis[route[i][0]][e[j].from] + mpdis[e[j].from][route[i][1]] ==
                  mpdis[route[i][0]][route[i][1]] &&
              mpdis[e[j].from][route[i][1]] == mpdis[num1][route[i][1]] + 1) {
            dp[i][e[j].from][1]++;
            assert(fe[j][i] == 0);
            fe[j][i] = 1;
            if (dp[i][e[j].from][1] == dp[i][e[j].from][0]) {
              q1[r1++] = e[j].from;
              if (r1 == maxn) r1 = 0;
              if (dis[e[j].from] == inf && is[i][e[j].from]) {
                dis[e[j].from] = dis[num] + 1;
                q[r++] = e[j].from;
                if (r == maxn) r = 0;
              }
            }
          }
        }
      }
    }
  }
  if (dis[from] == inf) dis[from] = -1;
  cout << dis[from] << endl;
  return 0;
}
