Circular Maze

아직 제출이 없습니다시간 제한2초메모리 제한2048 MB

문제

You are given a circular maze such as the ones shown in the figures.

Determine if it can be solved, i.e., if there is a path which goes from the center to the outside of the maze which does not touch any wall. The maze is described by nn walls. Each wall can be either circular or straight.

  • Circular walls are described by a radius rr, the distance from the center, and two angles θ_1θ\_1, θ_2θ\_2 describing the beginning and the end of the wall in the clockwise direction. Notice that swapping the two angles changes the wall.
  • Straight walls are described by an angle θθ, the direction of the wall, and two radii r_1<r_2r\_1 < r\_2 describing the beginning and the end of the wall.

Angles are measured in degrees; the angle 00 corresponds to the upward pointing direction; and angles increase clockwise (hence the east direction corresponds to the angle 9090).

입력

Each test contains multiple test cases. The first line contains an integer tt (1t201 ≤ t ≤ 20) — the number of test cases. The descriptions of the tt test cases follow.

The first line of each test case contains an integer nn (1n50001 ≤ n ≤ 5000) — the number of walls.

Each of the following nn lines each contains a character (C for circular, and S for straight) and three integers:

  • either rr, θ_1θ\_1, θ_2θ\_2 (1r201 ≤ r ≤ 20 and 0θ_1,θ_2<3600 ≤ θ\_1, θ\_2 < 360 with θ_1 θ_2θ\_1 \ne θ\_2) if the wall is circular,
  • or r_1r\_1, r_2r\_2 and θθ (1r_1<r_2201 ≤ r\_1 < r\_2 ≤ 20 and 0 θ<3600 ≤ θ < 360) if the wall is straight.

It is guaranteed that circular walls do not overlap (but two circular walls may intersect at one or two points), and that straight walls do not overlap (but two straight walls may intersect at one point). However, circular and straight walls can intersect arbitrarily

출력

For each test case, print YES if the maze can be solved and NO otherwise.