Under construction

Still being built. Things may change

Geometry Problem

Time limit4sMemory limit1024 MB

Summary
Given two triangles with integer vertices and constant velocities, find the earliest time they collide, or report NO COLLISION if they never touch.
Level

Medium7 of 10

Topics
Geometry, Math
Solved
No attempts yet

Problem

Tired of all the geometry problems in programming contests, you decided to leave contests and get into game development. There were more geometry problems waiting for you anyway. You designed a two player 2-D arcade game. The first player throws a triangular metal piece in a chosen direction. The second player then throws another triangular metal piece to hit the first player's piece. You want to know whether the two pieces will collide.

At the instant the second player throws his piece, you store the position and velocity of both pieces and call this time 0. The game does not allow the pieces to already be in collision at time 0. Compute the time at which the two pieces collide.

Input

The first line contains TT, the number of test cases. Each test case has two lines. The first line describes the first player's piece, and the second line describes the second player's piece. Each description has 8 space separated integers x1,y1,x2,y2,x3,y3,vx,vyx_1, y_1, x_2, y_2, x_3, y_3, v_x, v_y. (xi,yi)(x_i, y_i) is the position of the ii-th vertex of the piece, and vxv_x and vyv_y are the x and y components of the piece's velocity.

Output

For each test case, print one line with the earliest time at which the two pieces collide. The answer must have a relative or absolute error of at most 10−910^{-9}. If the pieces never collide, print "NO COLLISION" (without quotes).

Constraints

1≤T≤1001 \le T \le 100

−107≤x1,y1,x2,y2,x3,y3,vx,vy≤107-10^7 \le x_1, y_1, x_2, y_2, x_3, y_3, v_x, v_y \le 10^7

Examples1

  1. Example 1

    Input
    2
    0 0 1 0 0 -1 1 0
    2 0 3 0 2 -1 0 0
    0 0 1 0 0 -1 5 0
    2 0 3 0 2 -1 5 0
    
    Expected output
    1.000000000
    NO COLLISION