#include <bits/stdc++.h>
using namespace std;
int dp[int(1e2) + 10][int(1e2) + 10];
vector<pair<int, int> > com[int(1e2) + 10];
int n, m, s, e;
int ans[int(1e2) + 10], tt[int(1e2) + 10];
bool mark[int(1e2) + 10];
int dfs(int v, int tail) {
  if (v == tail) return ans[v];
  if (mark[v]) return tt[v];
  mark[v] = true;
  tt[v] = 0;
  for (int i = 1; i <= n; i++) {
    if (dp[v][i] + dp[i][tail] == dp[v][tail] && dp[v][i] == 1) {
      tt[v] = max(tt[v], dfs(i, tail));
    }
    tt[v] = min(ans[v], tt[v]);
  }
  return tt[v];
}
int main() {
  std::ios::sync_with_stdio(false);
  for (int i = 0; i < int(1e2) + 10; i++)
    fill(dp[i], dp[i] + int(1e2) + 10, int(1e9)), dp[i][i] = 0;
  fill(ans, ans + int(1e2) + 10, 1000);
  cin >> n >> m >> s >> e;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    dp[a][b] = 1;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
  if (dp[s][e] >= int(1e9)) return cout << -1, 0;
  int q;
  cin >> q;
  for (int l = 1; l <= q; l++) {
    int a, b;
    cin >> a >> b;
    if (dp[a][b] >= int(1e9)) continue;
    for (int i = 1; i <= n; i++) {
      if (dp[a][b] == dp[a][i] + dp[i][b]) {
        bool flag = false;
        for (int j = 1; j <= n; j++) {
          if (j != i && dp[a][i] == dp[a][j] && dp[i][b] == dp[j][b]) {
            flag = 1;
            break;
          }
        }
        if (!flag) {
          com[l].push_back({dp[a][i], i});
        }
      }
    }
  }
  for (int i = 1; i <= q; i++) sort(com[i].begin(), com[i].end());
  fill(ans, ans + int(1e2) + 10, 500);
  fill(tt, tt + int(1e2) + 10, 500);
  ans[e] = 0;
  for (int c = 0; c <= 500; c++) {
    for (int i = 1; i <= q; i++) {
      fill(mark, mark + int(1e2) + 10, false);
      for (pair<int, int> b : com[i]) {
        int temp = dfs(b.second, com[i][com[i].size() - 1].second) + 1;
        ans[b.second] = min(ans[b.second], temp);
      }
    }
  }
  cout << (ans[s] > 200 ? -1 : ans[s]);
  return 0;
}
