Given a sequence of non-negative integers , and two sequences of length , and . It is guaranteed that all are positive integers.
You need to perform operations in order from to . In the -th operation, you modify the current sequence based on the value of :
If , you must perform for all .
If , you must perform for all .
If , you can freely choose to perform either of the two operations mentioned above.
After all operations are completed, determine whether it is possible to make all elements in sequence equal.
Additional notes regarding the and operations are as follows:
The binary operation is defined as the smallest non-negative integer that is not equal to and not equal to . For example: , .
For the greatest common divisor , it is specifically defined that .
输入格式
The input contains multiple test cases. The first line contains an integer (), the number of test cases.
For each test case:
The first line contains two integers (), representing the length of sequence and the number of operations.
The second line contains non-negative integers (), representing the initial sequence.
The next lines each contain two integers (, ), representing the type parameter and value parameter of the -th operation.
It is guaranteed that across all test cases, and .
输出格式
For each test case, output one line. If it is possible to make all numbers equal after all operations are finished, output “Yes”; otherwise, output “No”.
For the first test case: in the first operation, choose to apply the operation, and the sequence becomes . In the following operations, no matter which operation you choose, the elements of the sequence will always remain equal, so output “Yes”.
For the second test case: the only operation is , , so you can only choose the operation.
The final sequence becomes , and it is impossible to make all numbers equal, so output “No”.