#include <bits/stdc++.h>
using namespace std;
const int N = int(1e2) + 7;
const int inf = int(1e6);
int x[N], y[N], u, v, n, m, s, t, k;
int d[N][N], f[N][N], must[N][N], dis[N], deg[N][N];
bool del[N][N];
queue<int> q;
vector<int> adj[N], rg[N][N];
bool can(int s, int t, int x) {
  return d[s][x] + d[x][t] == d[s][t] && d[s][t] < inf;
}
bool bfs(int s, int t, int x) {
  if (!can(s, t, x)) return 1;
  if (x == s || x == t) return 0;
  fill(dis, dis + n + 1, inf);
  dis[s] = 0;
  for (q.push(s); q.size(); q.pop()) {
    u = q.front();
    for (int& v : adj[u]) {
      if (v == x) continue;
      if (dis[v] > dis[u] + 1) {
        dis[v] = dis[u] + 1;
        q.push(v);
      }
    }
  }
  return dis[t] == d[s][t];
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  if (fopen("test"
            ".inp",
            "r")) {
    freopen(
        "test"
        ".inp",
        "r", stdin);
    freopen(
        "test"
        ".out",
        "w", stdout);
  }
  cin >> n >> m >> s >> t;
  for (int i = 1; i <= n; ++i) {
    fill(d[i], d[i] + n + 1, inf);
    fill(f[i], f[i] + N, inf);
    d[i][i] = 0;
  }
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    adj[u].emplace_back(v);
    d[u][v] = 1;
  }
  for (int x = 1; x <= n; ++x) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        d[i][j] = min(d[i][j], d[i][x] + d[x][j]);
      }
    }
  }
  cin >> k;
  for (int i = 1; i <= k; ++i) {
    cin >> x[i] >> y[i];
    for (int j = 1; j <= n; ++j) must[i][j] = bfs(x[i], y[i], j) ^ 1;
  }
  deque<pair<int, int> > dp;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (can(x[j], y[j], i)) {
        for (int& v : adj[i]) {
          if (d[x[j]][i] + 1 + d[v][y[j]] == d[x[j]][y[j]]) {
            ++deg[i][j];
            rg[v][j].emplace_back(i);
          }
        }
        if (t == i) dp.push_back({i, j}), f[i][j] = 1;
      }
    }
  }
  int res = inf;
  while (dp.size()) {
    tie(u, v) = dp.front();
    dp.pop_front();
    if (del[u][v]) continue;
    if (u == s && must[v][u]) res = min(res, f[u][v]);
    del[u][v] = 1;
    if (must[v][u]) {
      for (int i = 1; i <= k; ++i) {
        if (i != v && can(x[i], y[i], u)) {
          if (f[u][i] > f[u][v] + 1) {
            f[u][i] = f[u][v] + 1;
            dp.push_back({u, i});
          }
        }
      }
    }
    for (int& x : rg[u][v]) {
      if (--deg[x][v] == 0 && f[x][v] > f[u][v]) {
        f[x][v] = f[u][v];
        dp.push_front({x, v});
      }
    }
  }
  cout << (res >= inf ? -1 : res);
}
