#include "stdio.h"
#include "math.h"
int main()
{
int h, m, s;
int n,th0;
double th;
scanf("%d",&n);
while (n--)
{
scanf("%d %d %d",&h,&m,&s);
th = fabs( (6*m+ (double)s/10)-( (double)(60*m+s)/120+30*(h) ) );
if(th>180) th = 360-th;
th0 = floor(th);
printf("%d/n",th0);
// printf("%.2f/n",th);
}
return 0;
}