#include <bits/stdc++.h>
using namespace std;
constexpr int N = 100 + 10;
constexpr int MOD = 1e9 + 7;
int n, m, a, b, dist[N], main_dist[N][N], u, v, s[N], t[N], limit,
    new_dist[N][N];
vector<int> node[N], bus[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> a >> b;
  memset(main_dist, 63, sizeof(main_dist));
  memset(dist, -1, sizeof(dist));
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    main_dist[u][v] = 1;
    node[u].push_back(v);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        main_dist[j][k] =
            min(main_dist[j][k], main_dist[j][i] + main_dist[i][k]);
  cin >> limit;
  for (int i = 0; i < limit; i++) cin >> s[i] >> t[i];
  for (int i = 1; i <= n; i++) {
    memset(new_dist, 63, sizeof(new_dist));
    for (int j = 1; j <= n; j++) {
      if (j == i) continue;
      for (auto k : node[j])
        if (k != i) new_dist[j][k] = 1;
    }
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        for (int l = 1; l <= n; l++)
          new_dist[k][l] = min(new_dist[k][l], new_dist[k][j] + new_dist[j][l]);
    for (int j = 0; j < limit; j++)
      if (main_dist[s[j]][t[j]] < new_dist[s[j]][t[j]] && t[j] != i)
        bus[i].push_back(t[j]);
  }
  dist[b] = 0;
  for (int i = 1; i <= n; i++) {
    vector<int> vec;
    memset(new_dist, 63, sizeof(new_dist));
    for (int j = 1; j <= n; j++) {
      if (dist[j] != -1) continue;
      for (auto k : node[j])
        if (dist[k] == -1) new_dist[j][k] = 1;
    }
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        for (int l = 1; l <= n; l++)
          new_dist[k][l] = min(new_dist[k][l], new_dist[k][j] + new_dist[j][l]);
    for (int j = 1; j <= n; j++) {
      if (dist[j] != -1) continue;
      for (auto k : bus[j]) {
        if (main_dist[j][k] < new_dist[j][k]) {
          vec.push_back(j);
          break;
        }
      }
    }
    for (auto j : vec) dist[j] = i;
  }
  cout << dist[a] << '\n';
  return 0;
}
