A remote city has a park which contains zoo chain in it. The zoo chain containsr r zoos, labeled 1 through r. Bidirectional roads connect the zoos to form a simple cycle — a road connects zoos 1 and 2, zoos 2 and 3, and so on, and additionally a road connects zoos r and 1. The center of each zoo contains an identical animal, and all but one of the zoos has a beautiful animal having unique colour of skin currently living in the cage of that zoo. The remaining zoo holds only an empty cage.
The managers of the zoos want to rearrange the animals in a new order. To do this, they repeat the following process: First, they choose a zoo directly adjacent to the zoo containing an empty cage. Then, they very carefully and painstakingly carry the animal in this zoo across the adjoining road and place it in the empty cage.
You have to determine if it is possible for the managers of the zoos to arrange the animals in the desired order.
Input:
The first line contains a single integer - number of test cases.
For each test case the format of input is as follows:
Output:
For each test case print "YES" (without quotes) if the rearrangement can be done in the existing network, and "NO" otherwise in separate lines.
Constraints:
(1 ≤ T ≤ 100)
(2 ≤ r ≤ 200 000)
(0 ≤ pi < r )
(0 ≤ qi < r )
Problem Setter: MAHIMA SINGH
Explanation:
In the first test case, the managers can first move animal 1 from zoo 1 to zoo 2, then move animal 2 from zoo 3 to zoo 1, and finally move animal 1 from zoo 2 to zoo 3.
In the second test case, the managers can simply move animal 1 from zoo 1 to zoo 2.
In the third test case, no sequence of movements results in the desired position.