#include<iostream>
#include<algorithm>
using namespace std;
int n,h,m;
int a,b,c,d;
char ch;
int main(){
  cin>>n;
  while(n--){
    cin>>h>>ch>>m;
    a=h*30+(m/12);
    b=m*6;
    
   
    c=max(a,b)-min(a,b);
    if(c>180)c=min(a,b)+(360-max(a,b));

    cout << a<< ' '<<b<<' '<<c<<endl;
    /*
    if(0<=c&&c<30){
      cout<<"alert"<<endl;
    }else if(90<=c&&c<=180){
      cout<<"safe"<<endl;
    }else{
      cout<<"warning"<<endl;
    }
    */
  }
  return 0;
}