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;
void readi(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readll(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
void writes(string s) { puts(s.c_str()); }
void writeln() { writes(""); }
void writei(int x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
void writell(long long x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline long long inc(int &x) { return ++x; }
inline long long inc(long long &x) { return ++x; }
inline long long inc(int &x, long long y) { return x += y; }
inline long long inc(long long &x, long long y) { return x += y; }
inline double inc(double &x, double y) { return x += y; }
inline long long dec(int &x) { return --x; }
inline long long dec(long long &x) { return --x; }
inline long long dec(int &x, long long y) { return x -= y; }
inline long long dec(long long &x, long long y) { return x -= y; }
inline double dec(double &x, double y) { return x -= y; }
inline long long mul(int &x) { return x = ((long long)x) * x; }
inline long long mul(long long &x) { return x = x * x; }
inline long long mul(int &x, long long y) { return x *= y; }
inline long long mul(long long &x, long long y) { return x *= y; }
inline double mul(double &x, double y) { return x *= y; }
inline long long divi(int &x) {
  long long ans, l, r, mid;
  ans = 0;
  l = 0;
  r = 0x3fffffff;
  while (l < r) {
    mid = (l + r) / 2;
    if (mid * mid < x) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid;
  }
  return ans;
}
inline long long divi(long long &x) {
  long long ans, l, r, mid;
  ans = 0;
  l = 0;
  r = 0x3fffffff;
  while (l < r) {
    mid = (l + r) / 2;
    if (mid * mid < x) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid;
  }
  return ans;
}
inline long long divi(int &x, long long y) { return x /= y; }
inline long long divi(long long &x, long long y) { return x /= y; }
inline double divi(double &x, double y) { return x /= y; }
inline long long mod(int &x, long long y) { return x %= y; }
inline long long mod(long long &x, long long y) { return x %= y; }
long long n, m, s, t, k, i, j, l, dp[105], dp2[105], dis[105][105],
    cnt[105][105], cer[105][105], ps[105], pt[105], _, x, y, col, vis[105];
long long dfs(long long x, long long y) {
  if (vis[x] == col) return dp2[x];
  vis[x] = col;
  dp2[x] = -1;
  int i;
  if ((1) <= ((n)))
    for (((i)) = (1); ((i)) <= ((n)); ((i))++)
      if (dis[x][i] == 1 && dis[x][i] + dis[i][y] == dis[x][y])
        dp2[x] = max(dp2[x], dfs(i, y));
  if (dp2[x] == -1) dp2[x] = 0x2222222222ll;
  return dp2[x] = min(dp2[x], dp[x] + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  ;
  memset((dis), (0x16), (sizeof((dis))));
  cin >> n >> m >> s >> t;
  if ((1) <= ((n)))
    for (((i)) = (1); ((i)) <= ((n)); ((i))++) dis[i][i] = 0;
  if ((1) <= ((m)))
    for (((i)) = (1); ((i)) <= ((m)); ((i))++) {
      cin >> x >> y;
      if (x != y) dis[x][y] = 1;
    }
  if ((1) <= ((n)))
    for (((l)) = (1); ((l)) <= ((n)); ((l))++)
      if ((1) <= ((n)))
        for (((i)) = (1); ((i)) <= ((n)); ((i))++)
          if ((1) <= ((n)))
            for (((j)) = (1); ((j)) <= ((n)); ((j))++)
              dis[i][j] = min(dis[i][j], dis[i][l] + dis[l][j]);
  cin >> k;
  if ((1) <= ((k)))
    for (((i)) = (1); ((i)) <= ((k)); ((i))++) {
      cin >> ps[i] >> pt[i];
      if ((1) <= ((n)))
        for (((j)) = (1); ((j)) <= ((n)); ((j))++) {
          if (dis[ps[i]][j] + dis[j][pt[i]] <= n &&
              dis[ps[i]][j] + dis[j][pt[i]] == dis[ps[i]][pt[i]])
            cnt[i][dis[ps[i]][j]]++;
        }
      if ((1) <= ((n)))
        for (((j)) = (1); ((j)) <= ((n)); ((j))++) {
          if (dis[ps[i]][j] + dis[j][pt[i]] <= n &&
              dis[ps[i]][j] + dis[j][pt[i]] == dis[ps[i]][pt[i]] &&
              cnt[i][dis[ps[i]][j]] == 1)
            cer[i][j] = 1;
        }
    }
  memset((dp), (0x16), (sizeof((dp))));
  dp[t] = 0;
  memset((dp2), (0x16), (sizeof((dp2))));
  if ((1) <= ((0x3bbbbbbb)))
    for (((_)) = (1); ((_)) <= ((0x3bbbbbbb)); ((_))++) {
      bool chg = 0;
      if ((1) <= ((k)))
        for (((i)) = (1); ((i)) <= ((k)); ((i))++) {
          if ((1) <= ((n)))
            for (((j)) = (1); ((j)) <= ((n)); ((j))++) {
              if (cer[i][j]) {
                col++;
                if (dfs(j, pt[i]) < dp[j]) {
                  dp[j] = dfs(j, pt[i]);
                  chg = 1;
                }
              }
            }
        }
      if (!chg) break;
    }
  if (dp[s] >= 0x2222222222ll)
    cout << -1;
  else
    cout << dp[s];
  return 0;
}