clock-mania

In PIET's CS Deparment there is a contest of Geometry. In this contest students are told to find minimum angle between hour and minute hand.

Input:
The first line contains the number of test cases, T. T lines follow, each of which contains two integer Hour hand H and minute hand M .

Output:
Print the minimum angle between the hands.

Constraints
1 ≤ T ≤ 100 
01 ≤ H ≤ 12
01 ≤ M ≤ 59 

SAMPLE INPUT
2
12 30
06 00

SAMPLE OUTPUT
165 
180

Explanation

In first input time is 12:30 i.e. hour hand is in middle of 12 and 1 & minute hand is pointing at 6 which makes angle of 165 degrees. 

In Second input time is 06:00 i.e. hour hand is at 12 and minute hand is at 6 which makes angle of 180 degrees.

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import sys
import math
T = int(sys.stdin.readline())
for i in range(T):
	line = sys.stdin.readline().split()
	hh = int(line[0])
	mm = int(line[1])
	hh = hh%12*30 + mm/2
	mm = 6*mm
	#print hh,mm
	print(min(abs(hh-mm),360-abs(hh-mm)))


for _ in range(eval(input())):
	hr,mn=list(map(int,input().split()))
	if hr==12:
		hr=0
	ahr=int(hr*30)+int(mn*0.5)
	amn=int(mn*6)
	angle=abs(ahr-amn)
	if angle>180:
		angle=360-angle   
	print(angle)    


t=int(input())
for i in range(t):
	hr,mi=list(map(int,input().split()))
	
	hd=30*hr
	md=30*mi//5
	ed=30*md//360
	hd=hd+ed
	print((min(abs(hd-md),abs(360-abs(hd-md)))));



'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=int(input())
i=0
while i<t:
	h,m=input().split()
	h=int(h)
	m=int(m)
	hour=(h*60+m)*1/2
	mini=6*m;
	ans=hour-mini
	ans=abs(ans)
	ans=min(360-ans,ans)
	print(ans)
	i=i+1


t=eval(input())
while t>0:
	a,b=input().split()
	h=int(a)
	m=int(b)
	if h==12:
		h=0
	if m==60:
		m=0
	k=m*6
	l=(h*30)+(m*6/12)
	a=abs(k-l)
	if a>=180:
		print(360-a)
	else:
		print(a)
	t=t-1


c = int(input())
for i in range(c):
	ip = input()
	ip = ip.split(' ')
	ip =list(map(int, ip))
	#print ip
	h = ip[0] * 30 + float(ip[1] / 2) 
	m = ip[1] * 6
	a = 0
	if h > m:
		a = h - m
	else:
		a = m - h 
		
	if a > 180:
		a = 360 - a
	print(int(a))	


import math
for _ in range(eval(input())):
	h,m=list(map(int,input().split()))
	x=(h*60+m)/2-(m*6)
	x=math.fabs(x)
	print(int(min(360-x,x)))