Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Simple

By kitorp, DarkknightRHZ · Limits 1s, 512 MB

Because all the problems are so hard these days, this is a very simple problem. Suppose you are given co-ordinates of two points A & B in 2D plane, an angle M and a stick of length L. One end of the stick is in point B and it creates M degree angle with the line AB in anti clockwise direction. It means that if one end of the stick is point B and another end is point C then angle B is equal to M and Length of BC is equal to L . You have to tell the co-ordinates of the other end point of the stick, that is the co-ordinates of point C .

Input

First line will contains T, the number of test cases .
Then for each of case, there will be line containing 6 integers Ax, Ay, Bx, By, M and L .

1<=T<=1000

0<=Ax,Ay,Bx,By<=10000

0<=M<=180

1<=L<=10000

Ax<=Bx

Ay<=By

Output

For each case, print two numbers X and Y , the co-ordinates of the other end point of the stick rounded to the closest integer number in a line. See sample test case for better understanding.

Sample

InputOutput
4
0 0 1 1 45 1
0 0 0 5 90 5
1 2 5 2 180 3
923 557 6907 5317 76 8111
1 0
5 5
8 2
10271 -2064


The figure is given for test case 1.

Discussion

Statistics


70% Solution Ratio

ovis96Earliest, May '18

mridul_sustFastest, 69.7s

ovis96Lightest, 131 kB

NirjhorShortest, 614B

Submit

Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.