#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, m, s, t, d[N][N], ans[N][N], deg[N][N];
bool vis[N][N];
vector<int> who[N], adj[N];
vector<int> upd[N][N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> s >> t;
  --s, --t;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) d[i][j] = (i != j) * (1 << 29);
  for (int i = 1, v, u; i <= m; i++) {
    cin >> v >> u;
    adj[v].push_back(u);
    --v, --u;
    d[v][u] = 1;
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  int k;
  cin >> k;
  for (int i = 0, v, u; i < k; i++) {
    cin >> v >> u;
    --v, --u;
    vector<int> vec, cnt(n + 5);
    if (d[v][u] == 1 << 29) continue;
    for (int k = 0; k < n; k++)
      if (d[v][k] + d[k][u] == d[v][u]) {
        cnt[d[v][k]]++;
        for (int nxt = 0; nxt < n; nxt++)
          if (d[v][nxt] + d[nxt][u] == d[v][u] &&
              d[v][nxt] == d[v][k] + d[k][nxt] && d[k][nxt] == 1) {
            upd[nxt][i].push_back(k), deg[k][i]++;
          }
      }
    for (int k = 0; k < n; k++)
      if (d[v][k] + d[k][u] == d[v][u] && cnt[d[v][k]] == 1) vec.push_back(k);
    for (auto v : vec) who[v].push_back(i);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < k; j++) ans[i][j] = 1 << 30;
  deque<pair<int, int>> q;
  swap(s, t);
  for (auto i : who[s]) {
    ans[s][i] = 1;
    q.push_front({s, i});
  }
  for (int i = 0; i < n; i++) sort(who[i].begin(), who[i].end());
  int base_dige = k;
  while (q.size()) {
    pair<int, int> f = q.front();
    q.pop_front();
    int v = f.first, k = f.second;
    if (vis[v][k]) continue;
    vis[v][k] = true;
    for (auto u : upd[v][k]) {
      deg[u][k]--;
      if (deg[u][k] == 0 && ans[v][k] < ans[u][k]) {
        ans[u][k] = ans[v][k];
        q.push_front({u, k});
      }
    }
    auto it = lower_bound(who[v].begin(), who[v].end(), k);
    if (it == who[v].end()) continue;
    if (*it != k) continue;
    for (int i = 0; i < base_dige; i++)
      if (ans[v][k] + 1 < ans[v][i]) {
        ans[v][i] = ans[v][k] + 1;
        q.push_back({v, i});
      }
  }
  int o = 1 << 30;
  for (auto i : who[t]) o = min(o, ans[t][i]);
  cout << (o < 1 << 30 ? o : -1) << '\n';
  return 0;
}
