Problem: 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.

Solution (in PYTHON):

Solution:
import sys,math
def clockangles(h, m):
	an=0.5*(h*60+m)
	bn=6*m;
	ans = abs(int(an)-int(bn))
	return min(360-ans,ans)
for _ in xrange(input()):
	x=raw_input().split()
	h=int(x[0])
	m=int(x[1])
	if(m==60):
		m=0
	if(h==12):
		h=0
	ans=int((clockangles(h,m)))
	print ans