Multiplayer Pong (Large)

Two teams alternately return a reflecting ball in fixed order, and the team whose player misses loses, so decide the winner and the loser return count.

Hard8MathGame theorySimulationNo attempts yetTime limit5sMemory limit512 MB

Problem

Two teams play pong. Each player controls one paddle, which we treat as a single point, and one ball travels back and forth between the two teams. Inside a team the players must return the ball in a fixed cyclic order. In a three-player team the first touch belongs to P1, the next to P2, the next to P3, and only then is it P1's turn again. Play continues until some player fails to reach the ball. The ball then leaves the field and that player's team loses.

The field is a rectangle of height AA and width BB. Its lower left corner is (0,0)(0, 0), the horizontal coordinate xx runs from 00 to BB, and the vertical coordinate yy runs from 00 to AA. The team called LEFT guards the wall x=0x = 0 with NN paddles, and the team called RIGHT guards the wall x=Bx = B with MM paddles, one paddle per player. Every paddle of LEFT moves vertically at speed VV and every paddle of RIGHT moves vertically at speed WW, both in units per second. Paddles of the same team pass through each other freely.

The ball starts at height YY and horizontal position XX, and it moves VYV_Y units up and VXV_X units to the right every second. Each player sees the starting position of the ball and then places their own paddle anywhere on their own wall before play begins. When the ball reaches a horizontal wall (y=0y = 0 or y=Ay = A) it reflects, so the angle of incidence equals the angle of reflection. When the ball reaches a vertical wall, the player whose turn it is must have their paddle exactly at the arrival point. If the paddle is there, the ball bounces back. If it is not, that player's team loses. A player who is not on turn cannot touch the ball even when their paddle sits at the arrival point.

A velocity component can be 00. If VXV_X is 00, the ball never reaches a vertical wall, so play never ends.

Determine the final result, assuming every player plays optimally.

Input

The first line contains TT, the number of test cases. Each test case consists of four lines.

The first line contains AA and BB, the height and the width of the field.

The second line contains NN and MM, the number of players on the team guarding x=0x = 0 and the number of players on the team guarding x=Bx = B.

The third line contains VV and WW, the paddle speed of the first team and the paddle speed of the second team.

The fourth line contains YY, XX, VYV_Y and VXV_X: the vertical position, the horizontal position, the vertical speed and the horizontal speed of the ball.

All values are integers.

  • 1T1001 \le T \le 100
  • 2A,B101002 \le A, B \le 10^{100}
  • 0<X<B0 < X < B
  • 0<Y<A0 < Y < A
  • 1N,M101001 \le N, M \le 10^{100}
  • 1V,W101001 \le V, W \le 10^{100}
  • 10100VY,VX10100-10^{100} \le V_Y, V_X \le 10^{100}

Output

For each test case, print one line of the form Case #x: y, where xx is the test case number starting from 1 and yy is one of the following.

  • DRAW if the game can go on forever.
  • LEFT z if the team guarding x=0x = 0 wins, where zz is the largest number of times the opposing team can bounce the ball.
  • RIGHT z if the team guarding x=Bx = B wins, where zz is the largest number of times the opposing team can bounce the ball.

Note

The picture shows the play of the first test case of the first example. The ball reaches the right wall at time 0.3750.375, and the first RIGHT player intercepts it, for instance by starting with her paddle there and never moving it. It reaches the left wall at 0.8750.875, where the single LEFT player returns it. At 1.3751.375 it is back on the right wall and the second RIGHT player can put his paddle at the bounce point. At 1.8751.875 it is on the left wall again and the LEFT player arrives just in time, covering three units of distance in exactly the one second she has. The next arrival on the right wall is too far away for the first RIGHT player. The second RIGHT player could reach it, but the cyclic order forbids him from touching the ball. If RIGHT had one more player, she would return the ball, and then LEFT would lose, because the ball would come back too high for the single LEFT player.