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;
const double pi = acos(0) * 2;
template <class T>
inline T abs1(T a) {
  return a < 0 ? -a : a;
}
template <class T>
inline T max1(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T min1(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline T gcd1(T a, T b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd1(b, a % b);
}
template <class T>
inline T lb(T num) {
  return num & (-num);
}
template <class T>
inline int bitnum(T num) {
  int ans = 0;
  while (num) {
    num -= lb(num);
    ans++;
  }
  return ans;
}
long long pow(long long n, long long m, long long mod = 0) {
  long long ans = 1;
  long long k = n;
  while (m) {
    if (m & 1) {
      ans *= k;
      if (mod) ans %= mod;
    }
    k *= k;
    if (mod) k %= mod;
    m >>= 1;
  }
  return ans;
}
const int maxn = 200;
const int inf = 100000;
int n, m, from, to, ter, lno;
int head[maxn], tail[maxn];
int mp[maxn][maxn], mpdis[maxn][maxn];
int dis[maxn];
int q[maxn], l, r, dp[maxn][maxn][2];
bool f[maxn], is[maxn][maxn];
int route[maxn][2];
bool fe[maxn * maxn * 2][maxn];
struct edge {
  int to, nxt1, from, nxt2;
} e[maxn * maxn * 2];
int main() {
  scanf("%d%d%d%d", &n, &m, &from, &to);
  from--;
  to--;
  memset(head, -1, sizeof(head));
  memset(tail, -1, sizeof(tail));
  for (int i = 0; i < 200; i++)
    for (int j = 0; j < 200; j++) {
      if (i == j)
        mpdis[i][j] = 0;
      else
        mpdis[i][j] = inf;
    }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    mpdis[a][b] = 1;
    e[i].to = b, e[i].from = a;
    e[i].nxt1 = head[a];
    e[i].nxt2 = tail[b];
    head[a] = i;
    tail[b] = i;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        if (mpdis[j][i] + mpdis[i][k] < mpdis[j][k])
          mpdis[j][k] = mpdis[i][k] + mpdis[j][i];
  int nt;
  scanf("%d", &nt);
  memset(mp, 0, sizeof(mp));
  for (int i1 = 0; i1 < nt; i1++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    route[i1][0] = a;
    route[i1][1] = b;
    if (mpdis[a][b] == inf) continue;
    memset(f, 0, sizeof(f));
    l = 0;
    r = 1;
    q[0] = a;
    f[a] = 1;
    bool ff = 0;
    while (l != r) {
      int num = q[l++];
      if (l == maxn) l = 0;
      f[num] = 0;
      ff = 0;
      if (l == r) ff = 1;
      int stat1 = 0;
      for (int i = head[num]; i != -1; i = e[i].nxt1) {
        if (mpdis[e[i].to][b] != mpdis[num][b] - 1) continue;
        if (!f[e[i].to]) {
          q[r++] = e[i].to;
          if (r == maxn) r = 0;
          f[e[i].to] = 1;
        }
        stat1++;
      }
      dp[i1][num][0] = stat1;
      if (ff) is[i1][num] = 1;
    }
  }
  l = 0;
  r = 1;
  for (int i = 0; i < n; i++) dis[i] = inf;
  dis[to] = 0;
  q[0] = to;
  for (; l != r;) {
    int num = q[l++];
    if (l == maxn) l = 0;
    for (int i = 0; i < nt; i++) {
      int q1[maxn], l1 = 0, r1 = 1;
      q1[0] = num;
      for (; l1 != r1;) {
        int num1 = q1[l1++];
        if (l1 == maxn) l1 = 0;
        for (int j = tail[num1]; j != -1; j = e[j].nxt2) {
          if (fe[j][i]) continue;
          if (mpdis[route[i][0]][e[j].from] + mpdis[e[j].from][route[i][1]] ==
                  mpdis[route[i][0]][route[i][1]] &&
              mpdis[e[j].from][route[i][1]] == mpdis[num1][route[i][1]] + 1) {
            dp[i][e[j].from][1]++;
            assert(fe[j][i] == 0);
            fe[j][i] = 1;
            if (dp[i][e[j].from][1] == dp[i][e[j].from][0]) {
              q1[r1++] = e[j].from;
              if (r1 == maxn) r1 = 0;
              if (dis[e[j].from] == inf && is[i][e[j].from]) {
                dis[e[j].from] = dis[num] + 1;
                q[r++] = e[j].from;
                if (r == maxn) r = 0;
              }
            }
          }
        }
      }
    }
  }
  if (dis[from] == inf) dis[from] = -1;
  cout << dis[from] << endl;
  return 0;
}