Deja vu of Go Players
InterviewTime limit1sMemory limit256 MB
Red moves first and each player can empty one of their own piles per turn; decide whether red can always force a win.
- Level
Easy3 of 10
- Topics
- Game theory, Implementation
- Solved
- No attempts yet
Problem
An ordinary sequence rather than magic codes? Rikka's opinion is much more important than the 'truth' itself. She soon felt sleepy and fell asleep to take a trip to dreamlands in passing.
Rikka found two elders playing Go when her sanity came back. The ethereal clouds, hardy vigorous pines, and rugged rocks shocked her. A fiction isekai! Excited, Rikka's eyes ran around and finally focused on the Go board.
The two players, wearing white and red respectively, were not playing Go. They divided the black and white pieces into piles and took turns removing them. They kept silent in response to her questions, so Rikka had to stand there and keep her eyes on the board.
The game looked unexpectedly simple. The red player starts with black piles, and the white player starts with white piles. They take turns removing any positive number of pieces from one of their own piles. Red moves first. The player who first removes all pieces assigned to them wins, and the other player has to drink.
Drinking is illegal for minors in Japan, so Rikka wonders whether she can ensure a win when she is the red player.
Input
The first line contains an integer , the number of test cases. Then test cases follow.
Each test case has the following format.
The first line contains two integers , the numbers of piles of the red and the white player.
The next line contains integers , where each integer is the number of pieces in a black pile of the red player.
The next line contains integers , where each integer is the number of pieces in a white pile of the white player.
Output
Output a string in one line: Yes if the red player, who moves first, can ensure a win, or No otherwise.