Where is the billiard ball going?
题号:NC214802
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

A billiard ball is hit on a rectangular billiard table with length L and width W, and an initial velocity is given to the billiard ball. If the billiard ball does not meet the border, it will move uniformly and in a straight line; It will bounce back according to the complete rigidity (the incident angle is equal to the shooting angle) when it encounters the border. If it happens to meet the corner of the billiard table, it will bounce back in the original way.

Suppose that the lower left corner of the billiard table is the coordinate origin (0, 0), and the radius of the billiard ball is r. It is known that the starting position of the billiard ball center is (px, py) and the initial velocity is (vx, vy).

Please calculate: after time t, where is the billiard ball going?

输入描述:

The first line contains one integer T(T ≤ 1,000), the number of test cases.
For each test case, there are eight integers in one line in the following format:L W r px py vx vy t
(10≤ L,W ≤ 1,024 , 1≤r<5 , r≤px≤L-r , r≤py≤W-r , -1,000≤vx,vy≤1,000 , 0≤t≤109)

输出描述:

For each case, your program will output the position of the billiard ball center after time t in one line.The position is represented by two integer coordinates separated by a space.

示例1

输入

复制
4
200 100 1 100 50 1 1 1
200 100 1 100 50 1 0 1000
200 200 1 100 100 1 1 1000
100 100 1 1 1 2 3 10000

输出

复制
101 51
90 50
90 90
9 13