408413: GYM103115 G cocktail with snake
Description
The favorite game of Mr.Cocktail is dota2. Serpentine walking is a useful skill to dodge the enemy's attack. Serpentine walking refers to the path of movement that keeps swing direction like a snake. Suppose the map is a n*m two-dimensional plane. Mr.Cocktail at the point (1,1) in initial.
He will first go to the right to the end, that is, point (n,1). Then turn and go one step upwards to point (n,2). Go to the left again to the end, that is, point (1,2),. Then go one step up, and go to the right again to the end.
Now the map size is n*m . The number of steps k of Cocktail's movement are known. Find the Manhattan distance from the position after k steps to the starting point according to the rule.
Manhattan distance Definition: The distance between two points measured along axes at right angles. In a plane with p1 at (x1, y1) and p2 at (x2, y2), it is |x1 - x2| + |y1 - y2|.
InputThe first line contains a positive integer T, which represents the number of groups to be tested. $$$(1 \leq T \leq 10^4)$$$
Next contains T lines, each row contains three integers $$$n, m, k(1 \leq n, m \leq 10^{18}, 0 \leq k \leq min(n*m-1, 10^{18}))$$$
OutputFor each test data, output a line of one coordinate to represent the answer. (A positive integer separated by two spaces represents the x and y coordinates respectively)
ExampleInput5 3 3 1 3 3 2 3 3 3 3 3 4 3 3 5Output
1 2 3 2 1