Resort

No attempts yetTime limit1sMemory limit128 MB

Problem

In the Byte Mountains there is a ski resort called Bytegary, famous for its cross-country ski tracks. Every track and every lift starts at one clearing and ends at another.

  • A ski track is a directed edge and is free to use. A two-way track is represented as two one-way tracks, one in each direction.
  • A ski lift is a directed edge; riding it once deducts a fixed number of points from your magnetic card, and unused points are never refunded. A two-way lift is likewise represented as two one-way lifts, and the cost may differ between the two directions.

Byteoni is currently at clearing bb with ss points left on his last card. He wants to get down to one of the base clearings at the foot of Bytegary (those numbered 11 through nn'), leaving as few points on the card as possible.

He may ride any track for free, and may ride a lift only when his current number of points is at least that lift's cost. You may assume it is always possible for him to reach a base clearing (he never gets stranded for lack of points).

Compute the smallest number of points that can be left on Byteoni's card when he reaches a base clearing.

Input

  • The first line contains two integers nn and nn' separated by a single space (1n<n10001 \le n' < n \le 1000). nn is the total number of clearings, numbered 11 through nn; the base clearings are those numbered 11 through nn'.
  • The second line contains the number of ski tracks kk (1k50001 \le k \le 5000).
  • Each of the next kk lines contains two distinct integers p1p_1 and p2p_2 (1p1p2n1 \le p_1 \ne p_2 \le n), a one-way track from p1p_1 to p2p_2.
  • The next line contains the number of lifts mm (1m3001 \le m \le 300).
  • Each of the next mm lines contains three integers q1q_1, q2q_2 and rr (1q1q2n1 \le q_1 \ne q_2 \le n, 1r10001 \le r \le 1000), a one-way lift from q1q_1 to q2q_2 costing rr points.
  • The last line contains two integers bb and ss (1bn1 \le b \le n, 1s20001 \le s \le 2000): the clearing Byteoni stands on and the number of points on his last card.

Output

Output a single integer: the smallest number of points that can be left on the card when Byteoni reaches a base clearing.