Game Rigging#4226

Game Rigging

1 second
64 megabytes
Medium

You've decided to host a StarCraft II tournament to decide who is the very best StarCraft II player at Stanford. Many of your friends are entering, and you want one of them to win because the prize is two tickets to the next StarCraft II World Finals! Luckily, you get to arrange the games and you have some information about which players will beat which others, i.e., match-ups that have a guaranteed outcome. The tournament is played as a series of games where in each game, two players (of your choice) who have not yet been eliminated play each other. This continues until only one player remains, and they are the winner. Can you set up the tournament so that one of your friends wins?

Input

The input consists of multiple test cases. Each test case starts with two integers (2 \leq N \leq 100000), the number of players in the tournament, (1 \leq K \leq N), the number of your friends in the tournament, and (0 \leq M \leq 100000), the number of match-ups for which you know the outcome. The next line contains integers between and , indicating which of the players are your friends (indices according to the order of the input). The following lines contain two integers each; a line containing indicates that if players and play each other, player will always beat player . The input is followed by a single line with N = K = 0, which should not be processed.

Output

For each test case, output one line which contains either yes or no indicating whether you can guarantee that one of your friends wins the tournament.

Examples

Example 1

Loading
Loading