#include #include using namespace std; int main(){ int a, b, d, t, m, x, y; string s; cin >> a >> b >> s; d = s.size() - 2; if( s.at(d) == '.'){ sscanf( s.c_str(),"UTC%d.%d", &t, &m ); if( m == 0 ){ t = t - 9; m = ( 10 - m ) % 10; } if( m != 0 ){ t = t - 8; m = ( m - 10 ) % 10; } } else{ sscanf( s.c_str(),"UTC%d", &t); t = t - 9; m = 0; } x = ( a * 60 + b + ( t * 60 + m * 6 ) ); y = ( a * 60 + b + ( t * 60 + m * 6 ) ); if( x < 0 ) x = 24 + ( x / 60 ); else x = x / 60; if( x >= 24 ) x = x % 24; if( x == 0 && y < 0 ){ x = 24 - 1; y = y = 60 + ( y % 60 ); } if( y < 0 ) y = 60 + ( y % 60 ); else y = y % 60; if( y >= 60 ) y = y % 60; if( 10 > x && 10 > y ) cout << "0" << x << ":" << "0" << y << endl; else if( 10 > x ) cout << "0" << x << ":" << y << endl; else if( 10 > y ) cout << x << ":" << "0" << y << endl; else cout << x << ":" << y << endl; return 0; }