#P7802. Fake Photo

Fake Photo

Fake Photo

Problem Description

Zhang3 has made a fake photo by Photoshop, and published it on the Internet. However, there are nn watches in the photo, showing different times. We assume that every watch has two hands: the hour hand and the minute hand, both moves at a uniform speed. Someone pointed out the problem of the watches. Then everyone began to doubt that it's a fake photo. To respond, Zhang3 will announce that the photo is taken at time xx, which is a time in a day. By choosing xx perfectly, she can make all of the watches look like showing time xx, with a small error. For example, if there are two watches showing 12:30:00\text{12:30:00} and 02:40:00\text{02:40:00} respectively, she can choose x=01:35:00x = \text{01:35:00} as if both watches are showing time xx. Specifically, we define the error of a hand of a watch as the angle between its actual location and its ideal location, where the ideal location is the correct location to show time xx. In the example above, the first watch shows 12:30:00\text{12:30:00} and x=01:35:00x = \text{01:35:00}, so the minute hand has an error of 3030^\circ while the error of the hour hand is a little bit larger. Please help Zhang3 choose such xx that the maximum error among all of the 2n2n hands is minimized. xx doesn't need to be an integer in seconds. Print the optimal error in degrees.

Input

The first line of the input gives the number of test cases T  (1T100)T \; (1 \le T \le 100). TT test cases follow. For each test case, the first line contains an integer n  (1n5×104)n \; (1 \le n \le 5 \times 10^4), the number of watches. Then nn lines follow, the ithi^\mathrm{th} of which contains a string of format $\text{HH:MM:SS} \; (0 \le \text{HH} \le 23, 0 \le \text{MM, SS} \le 59)$, describing the time the ithi^\mathrm{th} watch is showing. The sum of nn in all test cases doesn't exceed 10510^5.

Output

For each test case, print a line with a real number α  (0α180)\alpha \; (0 \le \alpha \le 180), representing the answer is α\alpha ^\circ. Your answers should have absolute or relative errors of at most 10610^{-6}.

Sample Input

2
2
12:30:00
02:40:00
3
00:00:00
23:59:59
06:30:30

Sample Output

32.5
91.55

Source

2020 Multi-University Training Contest 4