#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
vector<int> G1[maxn];
int n, m, a, b, q, mp[maxn][maxn], must[maxn][maxn], num[maxn];
int dist[maxn], vis[maxn], p[maxn], fb[maxn], tb[maxn], dp[maxn], Md[maxn];
struct Heap {
  int u, d;
  Heap(int _u = 0, int _d = 0) {
    u = _u;
    d = _d;
  }
  bool operator<(const Heap &H) const { return d > H.d; }
};
int Dijkstra(int s, int t, int del) {
  if (s == del || t == del) return 0x3f3f3f3f;
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= n; i++) dist[i] = 0x3f3f3f3f;
  dist[s] = 0;
  p[s] = -1;
  priority_queue<Heap> Q;
  Q.push(Heap(s, 0));
  while (!Q.empty()) {
    Heap o = Q.top();
    Q.pop();
    int u = o.u;
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = 0; i < G1[u].size(); i++) {
      int v = G1[u][i];
      if (v == del) continue;
      if (dist[v] > dist[u] + 1) {
        dist[v] = dist[u] + 1;
        p[v] = u;
        Q.push(Heap(v, dist[v]));
      }
    }
  }
  return dist[t];
}
vector<int> road;
int solve(int u, int k, int t) {
  if (vis[u] == t) return Md[u];
  int tmp = -1, sz = G1[u].size();
  vis[u] = t;
  for (int i = 0; i < sz; i++) {
    int v = G1[u][i];
    if (mp[fb[k]][u] + 1 + mp[v][tb[k]] == mp[fb[k]][tb[k]]) {
      tmp = max(tmp, solve(v, k, t));
    }
  }
  return Md[u] = min(tmp == -1 ? 0x3f3f3f3f : tmp, dp[u]);
}
int main() {
  int u, v, mv, md;
  memset(mp, 0x3f, sizeof mp);
  scanf("%d%d%d%d", &n, &m, &a, &b);
  for (int i = 1; i <= n; i++) mp[i][i] = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    G1[u].push_back(v);
    mp[u][v] = 1;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
      }
    }
  }
  scanf("%d", &q);
  for (int bs = 1; bs <= q; bs++) {
    scanf("%d%d", &u, &v);
    int d = Dijkstra(u, v, -1);
    mv = v;
    fb[bs] = u;
    tb[bs] = v;
    if (d == 0x3f3f3f3f) continue;
    while (v > 0) {
      road.push_back(v);
      v = p[v];
    }
    int sz = road.size();
    for (int i = sz - 1; i >= 0; i--) {
      int d1 = Dijkstra(u, tb[bs], road[i]);
      if (d1 > d) road.push_back(road[i]);
    }
    road.erase(road.begin(), road.begin() + sz);
    sz = road.size();
    for (int i = 0; i < sz; i++) must[bs][road[i]] = 1;
    road.clear();
  }
  int ok = 1, times = 1;
  memset(vis, 0, sizeof vis);
  memset(dp, 0x3f, sizeof dp);
  dp[b] = 0;
  while (ok) {
    ok = 0;
    for (int bs = 1; bs <= q; bs++) {
      for (int i = 1; i <= n; i++) {
        if (must[bs][i]) {
          int tmp = solve(i, bs, times++) + 1;
          if (tmp < dp[i]) ok = 1, dp[i] = tmp;
        }
      }
    }
  }
  printf("%d\n", dp[a] == 0x3f3f3f3f ? -1 : dp[a]);
  return 0;
}
