Under construction

Still being built. Things may change

Wheels

Time limit1sMemory limit256 MB

Summary
Wheel 1 turns once per minute clockwise, and each wheel linked by touches turns at inverse radius ratio with alternating direction.
Level

Medium5 of 10

Topics
Graph, BFS, Math
Solved
No attempts yet

Problem

A complicated machine is made of nn wheels, numbered 1 to nn. 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 TT.

Each test case starts with a line holding the number of wheels nn (1≤n≤10001 \le n \le 1000). Each of the next nn lines contains three integers xx, yy and rr (−10000≤x,y≤10000-10000 \le x, y \le 10000; 1≤r≤100001 \le r \le 10000), where (x,y)(x, y) is the center of the wheel and rr is its radius. The wheels are numbered 1 to nn in the order they are given.

Output

For each test case print nn lines. Line ii describes how wheel ii moves.

If the wheel turns, print p/q clockwise or p/q counterclockwise, where the irreducible fraction p/qp/q is the number of turns per minute. If qq is 1, print the integer pp instead of the fraction. If the wheel stands still, print not moving.

Examples2

  1. Example 1

    Input
    1
    5
    0 0 6
    6 8 4
    -9 0 3
    6 16 4
    0 -11 4
    
    Expected output
    1 clockwise
    3/2 counterclockwise
    2 counterclockwise
    3/2 clockwise
    not moving
    
  2. Example 2

    Input
    1
    1
    0 0 1
    
    Expected output
    1 clockwise