#Lutece0772. Police And The Thief
Police And The Thief
Migrated from Lutece 772 Police And The Thief
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There is a police and a thief in an chessboard, whose initial position is and . They move in turns. In each turn, one of the them must move to a neighboring grid(two grid are neighbored if they share a same edge). None of them can move out of the grid. When the police and the thief move into the same grid, the game ends and the thief was caught. Now you know the position of each other and who moves first, please figure out whether the thief would be caught if they both move wisely.
Input
In the first line, an integer is given indicating the number of test cases.
For each case, you can get two integers and in the first line. ();
The second line contain four integers . ()
is the initial position for the police, is the initial position for the thief.
The third line contain a string police
or thief
,it means that which one takes the first step.
Output
For each case, output the answer (YES
or NO
) in a line.
Samples
1
3 3
0 1 1 2
thief
YES
Resources
第五届ACM趣味程序设计竞赛第四场(正式赛)