Under construction

Still being built. Things may change

Clock

Time limit1sMemory limit512 MB

Summary
Given a clock time, compute the angles each hand makes with 12 o'clock and report the smallest of the three pairwise angles.
Level

Easy3 of 10

Topics
Math, Geometry, Implementation, Simulation
Solved
No attempts yet

Problem

One day, with nothing else to do, Yunpyo began observing a clock. At some point he realized that a clock is a single circle. He also drew rays from the center of the clock in the directions of the hour hand, the minute hand, and the second hand, and called the points where these rays meet the rim of the clock A, B, and C, with the center of the clock labeled O. While comparing the angles formed by any two of the rays OA, OB, and OC, he became curious about which angle is the smallest. Write a program that prints the smallest of the angles formed by any two of the rays OA, OB, and OC. The unit of angle is degrees (°).

Input

The first line gives the number of test cases T (1 ≤ T ≤ 3,000), and the following T lines each give one time as h hours m minutes s seconds (0 ≤ h ≤ 11, 0 ≤ m ≤ 59, 0 ≤ s ≤ 59; h, m, and s are integers) separated by spaces.

Output

For each of the T test cases, print the smallest of the angles formed by any two of the rays OA, OB, and OC.

An answer is accepted if its absolute or relative error from the exact value is at most 10-6.

Examples1

  1. Example 1

    Input
    1
    7 47 17
    
    Expected output
    50.058333