#include<bits/stdc++.h>
using namespace std;
string s[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"};intmain(){//freopen("datain.txt","r",stdin);
string a, b, c, d;
cin>>a>>b>>c>>d;int i;for(i =0; i < a.length()&& i < b.length(); i++){if(a[i]==b[i]&&isupper(a[i])&& a[i]<='G'){printf("%s",(s[a[i]-'A']).c_str());//cout<<endl<<i<<endl;break;}}//cout<<i<<endl;for(i++; i < a.length()&& i < b.length(); i++){if(a[i]==b[i]){if(isdigit(a[i])){printf(" %02d",a[i]-'0');break;}elseif(isupper(a[i])&& a[i]<='N'){printf(" %02d",a[i]-'A'+10);break;}}}for(i =0; i < c.length()&& i < d.length(); i++){if(c[i]==d[i]&&isalpha(c[i])){printf(":%02d",i);break;}}return0;}