Spectrum Explorer#3050

Spectrum Explorer

1 secondo
64 megabyte
Molto facile

Spectrum Explorer is an interactive computer game where a physicist explores the properties of visible light. The game's starting screen displays a number of circular platforms painted with colours from the visible light spectrum. More than one platform may be painted with the same colour (defined by a certain frequency), except for the two colours red and violet. The display contains only one red platform (the lowest frequency of THz) and one violet platform (the highest frequency of THz). A platform may intersect, or even contain, another platform with a different colour, but never merely touch its boundary. The display also shows a figure representing the explorer standing on the red platform.

The game's objective is to walk the explorer from the red platform to the violet platform and return back to the red platform. The walk must observe the following rules:

  1. If platform and platform have a common intersection and the frequency of the colour of platform is strictly smaller than the frequency of the colour of platform , then the explorer can walk from to during the walk from the red platform to the violet platform.

  2. If platform and platform have a common intersection and the frequency of the colour of platform is strictly greater than the frequency of the colour of platform , then the explorer can walk from to during the walk from the violet platform to the red platform.

  3. A coloured platform, with the exception of the red platform, disappears from display when the explorer walks away from it.

The developer of the game has programmed all the features of the game. All that is left is to ensure that the explorer has a chance to succeed in each instance of the game (that is, there is at least one valid walk from the red platform to the violet platform and then back again to the red platform). Your task is to write a program to check whether at least one valid path exists in each instance of the game.

Input

The input starts with an integer (1 \le K \le 50) indicating the number of scenarios, on a line by itself. The description for each scenario starts with an integer (2 \le N \le 300) indicating the number of platforms, on a line by itself, followed by lines that describe the colours, locations, and sizes of the platforms. Each line contains the frequency, followed by the - and -coordinates of the platform's center, and then the radius. The frequency is given as a real value with no more than three decimal places. The coordinates and radius are given, in meters, as integers. All values are separated by a single space. All integer values are in the range of to inclusive. In each scenario, all frequencies are in the range of to inclusive. Exactly one platform will have a frequency of and exactly one platform will have a frequency of .

Output

The output for each scenario consists of a single line that contains: Game is VALID, or Game is NOT VALID.

Esempi

Esempio 1

Loading
Loading