This page is still under construction.

Parts of this page are still being built. What you see may change.

Canyon Crossing

Time limit1sMemory limit128 MB

Summary
Decide whether a path from the left edge to the right edge of a rectangle avoids up to 1000 circular craters.
Level

Medium6 of 10

Topics
Union-find, Geometry
Solved
No attempts yet

Problem

Friendship One is a new rover that the Astronautical Center for Machinery ordered for exploring Triton, a moon of Neptune. It launches on March 18th, and the flight software has to be ready by then. Your boss handed you the part the whole mission rests on.

To collect the samples it needs, the rover has to cross a canyon. Friendship One drives over rough rock without trouble, but this canyon is covered with circular craters. If the rover drives into a crater it tips over and the mission fails. Craters can overlap each other and merge into wide regions that nothing can pass. Decide whether the canyon can be crossed.

The canyon is a rectangle of height HH and width WW. The rover starts at some point of the left edge X=0X = 0 and has to reach some point of the right edge X=WX = W. Its route is a continuous curve that stays inside the canyon, so 0≤Y≤H0 \le Y \le H holds the whole way, and the curve never meets a crater. Friendship One is tiny next to the craters, so treat it as a point with no area.

A crater is a closed disk, so its rim belongs to it. Two craters that meet at a single point are connected, and a crater whose rim reaches Y=0Y = 0 or Y=HY = H exactly touches that edge.

The picture shows the first case of the first example.

Input

The first line contains the number of test cases TT.

Each test case starts with a line of three integers HH, WW, and NN. HH and WW (1≤H,W≤100001 \le H, W \le 10000) are the height and the width of the canyon, and NN (0≤N≤10000 \le N \le 1000) is the number of craters. Each of the next NN lines describes one crater with three real numbers XX, YY, and RR separated by spaces, where (X,Y)(X, Y) is the center and RR is the radius. Every crater satisfies 0≤X≤W0 \le X \le W, 0≤Y≤H0 \le Y \le H, and R>0R > 0, and part of a crater may lie outside the canyon.

Output

Print one line per test case. Writing xx for the case number, counting from 1, print Case x: Clear To Go if Friendship One can cross the canyon, and Case x: Find Another Path if the craters block every route.

Examples1

  1. Example 1

    Input
    2
    100 200 3
    50.000 90.000 20.000
    70.000 60.000 20.000
    100.000 20.000 25.000
    10 20 2
    3.000 2.000 7.000
    4.000 5.000 6.500
    
    Expected output
    Case 1: Clear To Go
    Case 2: Find Another Path