//给出时间,求时针和分针,时针和秒针,分针和秒针的夹角
using namespace std ;
int s , t , h ;
int gcd(int a , int b)
{
if(b == 0)return a ;
return gcd(b , a%b) ;
}
int main()
{
// freopen("in.txt" , "r" , stdin) ;
int T ;
scanf("%d", &T) ;
while(T--)
{
scanf("%d:%d:%d" , &h , &t , &s) ;
int hd = (3600*h+60*t+s)%43200 ;
int td = (60*t+s)*12 ;
int sd = s*6*120 ;
int ans_1 = abs(((hd - td)));ans_1 = ans_1 > 21600 ? (43200-ans_1) : ans_1 ;
int ans_2 = abs(((hd -sd))) ;ans_2 = ans_2 > 21600 ? (43200-ans_2) : ans_2 ;
int ans_3 = abs(((sd - td)));ans_3 = ans_3 > 21600 ? (43200-ans_3) : ans_3 ;
int g1 = gcd(ans_1 , 120) ;
if(g1 == 120)
printf("%d" , ans_1/120) ;
else
printf("%d/%d" , ans_1/g1 , 120/g1) ;
int g2 = gcd(ans_2 , 120) ;
if(g2 == 120)
printf(" %d" , ans_2/120) ;
else
printf(" %d/%d" , ans_2/g2 , 120/g2) ;
int g3 = gcd(ans_3 , 120) ;
if(g3 == 120)
printf(" %d \n" , ans_3/120) ;
else
printf(" %d/%d \n" , ans_3/g3 , 120/g3) ;
}
}