Submit
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNext()) {
int t=sc.nextInt();
while(t-->0){
int h=sc.nextInt();
int m=sc.nextInt();
int s=sc.nextInt();
if (h>=12) {
h-=12;
}
double a=h*30+m*0.5+s/120.0; //注意精度
double b=m*6+s*0.1;
double ans=Math.abs(a-b);
if (ans>180) {
ans=360-ans;
}
System.out.println((int)ans);
}
}
}
}