#CF2236D. 全新鞑靼电视节目 / D. Brand New Tatar TV Show
全新鞑靼电视节目 / D. Brand New Tatar TV Show
D. Brand New Tatar TV Show
Source: Codeforces 2236D
Contest: Codeforces Round 1103 (Div. 3)
Time limit: 2 seconds
Memory limit: 256 megabytes
Statement
Dabir and Egor were not satisfied with the fame from the previous episode, so they decided to make another TV show: the guys play their favorite game on an array with their favorite integer .
Dabir moves first. On the first move, any element from the array can be chosen and removed. Let the previous chosen element be equal to . Then on the current move, except the very first one, a player must choose an element from the array such that and remove it from the array. The player who cannot make a move loses.
But since this was not just a game, but a real show-match, Arseniy (aka MAKAN) — the main celebrity of Omsk was invited again. As a guest celebrity, Arseniy was given the opportunity to make the first move in this match, that is, to make the very first move in the game instead of Dabir. However, it turns out Arseniy is a fan of Egor, so he wants his first move to guarantee Egor a winning strategy against any response from Dabir.
Determine whether Arseniy can make the first move for Dabir so that, no matter how Dabir plays, Egor wins.
Input
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases.
The first line of each test case contains two integers and () — the length of the array and the favorite integer of Dabir and Egor.
The second line contains integers ().
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, if there exists such a first move that with optimal play by both players Egor wins, output "YES", otherwise output "NO".
You can output "YES" and "NO" in any case (for example, "yES", "yes", and "Yes" will be accepted).
Note
In the first example, the only possible option is to choose the integer . After that, the array [] remains. Then Egor moves, then Dabir, and so on. Dabir will take the last , so Arseniy cannot choose a first move that makes Egor win.
In the second example, Arseniy can choose the integer as the first move. Then Egor will choose the integer , and Dabir will have no valid moves left, so Egor wins.
Examples
7
5 1
3 3 3 3 3
3 1
1 1 2
2 2
2 1
4 1
3 3 3 3
4 3
2 2 2 1
4 1
1 3 1 1
5 1
5 1 5 1 5
NO
YES
YES
YES
YES
NO
YES