Problem: Urpal lives in a big city. He has planned to meet his lover tonight. 

The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the date is planned in a restaurant in junction b. He wants to use public transportation to get to junction b. There are k bus transportation companies. At the beginning of every second, a bus from the i-th company chooses a random shortest path between junction si and junction ti and passes through it. There might be no path from si to ti. In that case no bus will leave from si to ti. If a bus passes through a junction where Urpal stands, he can get on the bus. He can also get off the bus at any junction along the path. 

Now Urpal wants to know if it's possible to go to the date using public transportation in a finite amount of time (the time of travel is the sum of length of the traveled roads) and what is the minimum number of buses he should take in the worst case.

At any moment Urpal knows only his own position and the place where the date will be. When he gets on the bus he knows only the index of the company of this bus. Of course Urpal knows the city map and the the pairs (si, ti) for each company.

Note that Urpal doesn't know buses velocity. 

Input

The first line of the input contains four integers n, m, a, b (2 ≤ n ≤ 100; 0 ≤ m ≤ n·(n - 1); 1 ≤ a, b ≤ n; a ≠ b). 

The next m lines contain two integers each ui and vi (1 ≤ ui, vi ≤ n; ui ≠ vi) describing a directed road from junction ui to junction vi. All roads in the input will be distinct. 

The next line contains an integer k (0 ≤ k ≤ 100). There will be k lines after this, each containing two integers si and ti (1 ≤ si, ti ≤ n; si ≠ ti) saying there is a bus route starting at si and ending at ti. Please note that there might be no path from si to ti, this case is described in the problem statement.

Output

In the only line of output print the minimum number of buses Urpal should get on on his way in the worst case. If it's not possible to reach the destination in the worst case print -1.

Examples

Input

7 8 1 7
1 2
1 3
2 4
3 4
4 6
4 5
6 7
5 7
3
2 7
1 4
5 7


Output

2


Input

4 4 1 2
1 2
1 3
2 4
3 4
1
1 4


Output

-1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2, class T3 = hash<T1>>
using umap = unordered_map<T1, T2, T3>;
template <class T>
using uset = unordered_set<T>;
template <class T>
using vec = vector<T>;
const long long infll = numeric_limits<long long>::max() >> 1;
const int inf = numeric_limits<int>::max() >> 1;
const int N = 101;
int n, m, k, s, t;
int opt[N][N];
bool sure[N][N];
vec<int> adj[N];
vec<int> rev[N];
vec<int> out[N][N];
struct Edge {
  int i, v, w;
};
struct Graph {
  int dst;
  vec<Edge> adj;
} graph[N][N];
void input() {
  cin >> n >> m >> s >> t;
  for (int i = 0; i < m; ++i) {
    int u;
    cin >> u;
    int v;
    cin >> v;
    adj[u].push_back(v);
    rev[v].push_back(u);
  }
}
void bfs(int source, int dst[N], vec<int> adj[N]) {
  fill(dst, dst + N, inf);
  queue<int> q;
  q.push(source);
  dst[source] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : adj[u]) {
      if (dst[v] > dst[u] + 1) {
        dst[v] = dst[u] + 1;
        q.push(v);
      }
    }
  }
}
void construct(int source, int sink, int index, vec<int> out[N]) {
  int dst_source[N];
  int dst_sink[N];
  int cnt[N] = {0};
  bfs(source, dst_source, adj);
  bfs(sink, dst_sink, rev);
  if (dst_source[sink] == inf) {
    return;
  }
  for (int u = 1; u <= n; ++u) {
    if (dst_source[u] + dst_sink[u] != dst_source[sink]) {
      continue;
    }
    if (dst_source[u] < inf) {
      cnt[dst_source[u]]++;
    }
  }
  for (int u = 1; u <= n; ++u) {
    if (dst_source[u] + dst_sink[u] != dst_source[sink]) {
      continue;
    }
    for (int v : adj[u]) {
      if (dst_source[v] + dst_sink[v] != dst_source[sink]) {
        continue;
      }
      if (dst_source[v] == dst_source[u] + 1) {
        out[u].push_back(v);
      }
    }
    if (cnt[dst_source[u]] == 1) {
      sure[index][u] = 1;
    }
  }
}
int bellman_ford() {
  for (int i = 0; i <= k; ++i) {
    for (int u = 1; u <= n; ++u) {
      if (u == t) {
        opt[i][u] = 0;
      } else {
        opt[i][u] = inf;
      }
    }
  }
  while (true) {
    bool changed = 0;
    for (int i = 0; i <= k; ++i) {
      for (int u = 1; u <= n; ++u) {
        int maxadj = -1;
        int origval = opt[i][u];
        for (int v : out[i][u]) {
          maxadj = max(maxadj, opt[i][v]);
        }
        if (maxadj == -1) {
          maxadj = inf;
        }
        opt[i][u] = min(opt[i][u], maxadj);
        for (int j = 0; j <= k; ++j) {
          if (sure[j][u]) {
            opt[i][u] = min(opt[i][u], opt[j][u] + 1);
          }
        }
        if (opt[i][u] != origval) {
          changed = 1;
        }
      }
    }
    if (!changed) {
      break;
    }
  }
  return opt[0][s];
}
void solve() {
  cin >> k;
  for (int i = 1; i <= k; ++i) {
    int x;
    cin >> x;
    int y;
    cin >> y;
    construct(x, y, i, out[i]);
  }
  int res = bellman_ford();
  if (res == inf) {
    cout << "-1\n";
  } else {
    cout << res << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  input();
  solve();
}