Skip to content

World War 3

Imagine World War 3 began and the University of Moratuwa became a heavily fortified enemy base, with only one route remaining open through the Sumanadasa building. This building is like a rectangular plot of land(HxW) represented by a xy coordinate plane (0 ≤ x ≤ W and 0 ≤ y ≤ H). The land is covered by four walls(x=0,y=0,x=W,y=H) and it is restricted to two gates. The Front Gate is in the middle of the front wall(y=0) and the Back Gate is in the middle of the back wall(y=H).

To keep watch on intruders, they've installed N number of CCTV cameras through the land. Each camera has a circular range region of radius R it can see, and they want to make sure no one sneaks from the Front Gate to the Back Gate without being spotted.

However, there's a bit of a loophole. Along the walls where the lines of trees are planted along the back wall(y=H) and the front wall(y=0). Therefore anyone can walk along the back and front walls without being detected by the cameras. However, some of these cameras may detect the left(x=0) and right(x=W) walls.

The challenge is to figure out if there's a secret path from the Front Gate to the Back Gate where someone can walk without being seen by any of the CCTV cameras.

Input Format

First line contains three space seperated integers: number of testcases T ,Height of the land(H) and Width of the land(W).

For each of the test case

  • First line contain two space seperated integers denoting N and R
  • Second line contains N space seperated integers denoting the x coordinates of each CCTV Camera
  • Third line contains N space seperated integers denoting the y coordinates of each CCTV Camera

Constraints

Number of CCTV Cameras and the Common Radius

  • 1 ≤ T ≤ 20
  • 1 ≤ N ≤ 1000
  • 1 ≤ R ≤ 5 x 108

The height and Width of the land

  • 1 ≤ H ≤ 109
  • 1 ≤ W ≤ 109

X and Y coordinates of each camera

  • 1 ≤ xi ≤ 109
  • 1 ≤ yi ≤ 109

Output Format

For each test cases print "CAN" in a seperate line if there is a secret path, and "CAN'T" in a seperate line if there isn't any secret path.

Sample Input 0

1 10 10
4 2
2 6 8 9 
5 5 9 1

Sample Output 0

CAN

Explanation 0

Figure is approximate. Note that the tree line which covers the cameras are very close to the front and back walls.

image

Sample Input 1

1 10 10
4 3
2 4 6 8
4 9 1 3  

Sample Output 1

CAN'T

By