1 #include<stdio.h>
2 int main()
3 {
4 int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
5 int year,mon,day,hour,min,sec,myear,mmon,mday,mhour,mmin,msec;
6 int i,n;
7 scanf("%d",&n);
8 while(n--)
9 {
10 scanf("%d%*c%d%*c%d%*c%d%*c%d%*c%d",&hour,&min,&sec,&day,&mon,&year);
11 for(i=1,m[0]=0;i<mon;i++)
12 m[0]+=m[i];
13 if(mon>2)
14 if(year%4==0&&year%100!=0||year%400==0)
15 m[0]++;
16 for(i=2000;i<year;i+=4)
17 if(i%100!=0||i%400==0)
18 m[0]++;
19 m[0]+=(year-2000)*365+day-1;
20 myear=m[0]/1000;
21 m[0]%=1000;
22 mmon=m[0]/100;
23 mday=m[0]%100;
24 m[0]=(hour*3600+min*60+sec)/0.864;
25 mhour=m[0]/10000;
26 m[0]%=10000;
27 mmin=m[0]/100;
28 msec=m[0]%100;
29 printf("%d:%d:%d %d.%d.%d\n",mhour,mmin,msec,mday+1,mmon+1,myear);
30 }
31 return 0;
32 }