import math import sys def input(): return sys.stdin.readline().rstrip() def main(): N = int(input()) for i in range(N): for i in range(7): s = input() x, y = map(float, s.split()) theta = math.atan2(y, x) / math.pi * 180 ans = (theta+5) % 60 - 5 print(ans) if __name__ == '__main__': main()