#include <stdio.h>
using namespace std;
int main(){
int a,b;
scanf("%d %d" , &a, &b);
//45 +
if (b >= 45) {
b-=45;
printf("%d %d", a ,b);
}
else if (a == 0) {
a += 23;
b = (60+b)-45;
printf("%d %d", a ,b);
}
else {
a -= 1;
b = (60+b)-45;
printf("%d %d", a ,b);
}
return 0;
}