Zombie Apocalypse

No attempts yetTime limit5sMemory limit512 MB

Problem

The year is 2020. You and your group are trapped in a town inside a city that zombies have wrecked. Your group is already infected, so you have to reach a hospital and get treated before you turn. Everyone in the group is a scientist, so sneaking past the zombies is safer than charging at them to force a way through. Zombies are everywhere, and on some roads sneaking through takes longer than on others. Splitting into several groups that move on their own is sometimes far safer than travelling together.

The infection did not go far enough to give these zombies eyes in the back of their heads. On some roads one direction is easy to sneak along while going back the other way is hard or impossible.

Find the largest number of people in your group who can avoid the zombies and reach a hospital before they turn.

Input

The first line holds the number of test cases. Each test case has the form below. Every value is an integer.

  • The first line holds the number of places nn. (1n10001 \le n \le 1000)
  • The next line holds the place ii where the group starts, the number of people gg in the group, and the time ss it takes to turn into a zombie. (1in1 \le i \le n, 1g1001 \le g \le 100, 1s1001 \le s \le 100)
    • Someone who reaches a hospital at time ss has found it before turning.
  • The next line holds the number of hospitals mm. (1mn1 \le m \le n)
  • Each of the next mm lines holds the number xx of a place that has a hospital. (1xn1 \le x \le n)
  • The next line holds the number of roads rr. (0r10000 \le r \le 1000)
  • Each of the next rr lines holds the road values aa, bb, pp, tt. (1a,bn1 \le a, b \le n, aba \ne b, 1p1001 \le p \le 100, 1t1001 \le t \le 100) The road runs from aa to bb, at most pp people step onto it at each unit of time, and crossing it takes tt units of time.

The group is at place ii at time 00. People step onto a road at integer times, and someone who steps onto a road at time τ\tau arrives at the far place at time τ+t\tau + t.

Between any pair of places there are at most 2 roads, one per direction. Every place is safe enough to stand and wait in for as long as you like, and there is no limit on how many people a place holds.

Output

For each test case, print on its own line the largest number of people who reach a hospital without being infected.