
#include <iostream>
using namespace std;
int main(void)
{
int inH = 0;
int inM = 0;
int outH = 0;
int outM = 0;
cin >> inH;
cin >> inM;
if ((inH < 0) || (23 < inH))
return 0;
if ((inM < 0) || (59 < inM))
return 0;
if ((inH == 0) && (inM < 45))
{
outH = 23;
outM = 15 + inM;
}
else
{
outH = (60 * inH + inM - 45) / 60;
outM = (60 * inH + inM - 45) % 60;
}
cout << outH<< " " << outM << '\n';
return 0;
}