#include <iostream>
using namespace std;
int main(void)
{
int h, m;
cin >> h >> m;
if ((m - 45) < 0)
{
m = 60 - (45 - m);
if ((h - 1) < 0)
h = 23;
else
h--;
}
else
m -= 45;
cout << h << " " << m;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKHZvaWQpCnsKCWludCBoLCBtOwoJY2luID4+IGggPj4gbTsKCglpZiAoKG0gLSA0NSkgPCAwKQoJewoJCW0gPSA2MCAtICg0NSAtIG0pOwoJCQoJCWlmICgoaCAtIDEpIDwgMCkKCQkJaCA9IDIzOwoJCWVsc2UKCQkJaC0tOwoJfQoJZWxzZQoJCW0gLT0gNDU7CgoJY291dCA8PCBoIDw8ICIgIiA8PCBtOwoJcmV0dXJuIDA7Cn0=