#include <bits/stdc++.h>
const int maxn = 105;
const int INF = 1e9;
using namespace std;
int n, m, a, b, k;
int f[maxn][maxn], dis[maxn][maxn], d[maxn][maxn];
int e[maxn * maxn][2], s[maxn], t[maxn];
bool sure[maxn][maxn];
vector<int> adj[maxn];
void floyd(int out, int f[][maxn]) {
  for (int i = 0; i < n; i++) {
    fill(f[i], f[i] + n, INF);
    f[i][i] = 0;
  }
  for (int i = 0; i < m; i++) f[e[i][0]][e[i][1]] = 1;
  for (int i = 0; i < n; i++) {
    if (i == out) continue;
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++) f[j][k] = min(f[j][k], f[j][i] + f[i][k]);
  }
}
bool relax(int v, int b) {
  int upd = -1;
  for (int u : adj[v])
    if (dis[u][t[b]] + 1 == dis[v][t[b]]) upd = max(upd, d[u][b]);
  if (upd == -1) upd = INF;
  for (int ib = 0; ib < k; ib++)
    if (sure[v][ib]) upd = min(upd, d[v][ib] + 1);
  if (upd < d[v][b]) return (d[v][b] = upd), true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> a >> b;
  a--;
  b--;
  for (int i = 0; i < m; i++) {
    cin >> e[i][0] >> e[i][1];
    e[i][0]--;
    e[i][1]--;
    adj[e[i][0]].push_back(e[i][1]);
  }
  floyd(-1, dis);
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> s[i] >> t[i];
    s[i]--;
    t[i]--;
    sure[s[i]][i] = sure[t[i]][i] = true;
  }
  for (int i = 0; i < n; i++) {
    floyd(i, f);
    for (int j = 0; j < k; j++)
      if (f[s[j]][t[j]] > dis[s[j]][t[j]]) sure[i][j] = true;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < k; j++) d[i][j] = INF;
  for (int j = 0; j < k; j++)
    if (sure[b][j]) d[b][j] = 0;
  for (int step = 0; step < n; step++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < k; j++) relax(i, j);
  int ans = INF;
  for (int j = 0; j < k; j++)
    if (sure[a][j]) ans = min(ans, d[a][j] + 1);
  cout << (ans < INF ? ans : -1) << endl;
  return 0;
}
