Geometry Problem
Time limit4sMemory limit1024 MB
Given two triangles with integer vertices and constant velocities, find the earliest time they collide, or report NO COLLISION if they never touch.
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 , 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 . is the position of the -th vertex of the piece, and and 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 . If the pieces never collide, print "NO COLLISION" (without quotes).
Constraints