Srikant is an agent in an Intelligence agency. He is now heading a secret mission against a group of terrorists. His colleague, JK has been taken hostage by the terrorists. They are determined to kill JK on th minute. There are cells (which are more like dungeons) numbered from to in the territory of the terrorists.
Srikant had taken a road map of these cells with him while leaving for his mission but lost it before he reached there. He is standing at the first cell. He had tried to memorize the road map before he lost it. But his memory is not very sharp. He only remembers one road or none for each cell. The road he remembers for cell leads to cell . If he cannot remember any road for a cell, it will be denoted by . The time required to move from one cell to the other is exactly minute.
The number of terrorists are guarding one or more cells. Srikant must kill all the terrorists within minutes to save his colleague.
To move from a cell, Srikant needs to kill all the terrorists guarding the cell if there are any. Else he will get killed. Time after killing all the terrorists doesn’t count because JK will already be safe by then as nobody would be there to harm him. If Srikant reaches a cell to kill a terrorist on the th minute, he cannot save JK because on that very minute the terrorist will shoot JK and kill him.
Srikant has rounds of bullets in his possession (each round consists of bullets). Srikant must shoot each of the terrorists a number of times in order to break his shield, disarm him and finally kill him. This number may vary from one terrorist to the other. If the required bullets to kill a terrorist are greater than the number of bullets Srikant is left with, he cannot kill the terrorist and the terrorist shoots him back. For the convenience of calculation, the time required to kill a terrorist or to reload the gun is not taken into consideration.
YOUR TASK IS TO FIND OUT IF SRIKANT CAN SAVE JK.
[N.B: The number of times a terrorist needs to be shot is equivalent to the number of bullets needed to kill him.]
The first line contains five space-separated integers , , that denote the number of cells, total number of terrorists, the minute on which JK will be killed and the number of rounds of bullets.
The second line contains space-separated integers that describe the cell numbers Srikant can move to.
Next lines contain two space-separated integers and that denote the cell number the th terrorist guards and the number of times he needs to be shot.
Print “Yes” if Srikant can save his colleague, otherwise print “No” (without quotes). You can print each letter in any case. For example, “YeS”, ”YES”, “yES”, “no”, ”NO” etc. are also acceptable.
Input | Output |
---|---|
6 4 6 3 6 4 2 0 3 5 2 3 3 5 5 4 6 5 | Yes |
Input | Output |
---|---|
5 3 3 3 5 4 0 0 2 1 18 2 4 2 2 | No |