Wheels
Time limit1sMemory limit256 MB
Wheel 1 turns once per minute clockwise, and each wheel linked by touches turns at inverse radius ratio with alternating direction.
Problem
A complicated machine is made of wheels, numbered 1 to . They are really cogwheels, but the cogs are so small that each wheel is modeled as a circle in the plane. Every wheel spins around its own center.
Two wheels never overlap, which means they share no interior point, but they may touch. When two wheels touch and one of them turns, the other turns as well, because their tiny cogs are locked together.
A force is applied to wheel 1 and to no other wheel, turning it exactly one turn per minute, clockwise. Find how fast every other wheel turns. You may assume the machine is not jammed, so the motion described by the input really happens.
Input
The first line contains the number of test cases .
Each test case starts with a line holding the number of wheels (). Each of the next lines contains three integers , and (; ), where is the center of the wheel and is its radius. The wheels are numbered 1 to in the order they are given.
Output
For each test case print lines. Line describes how wheel moves.
If the wheel turns, print p/q clockwise or p/q counterclockwise, where the irreducible fraction is the number of turns per minute. If is 1, print the integer instead of the fraction. If the wheel stands still, print not moving.