#include <stdio.h>
int main() {
int a, b;
scanf ("%d %d", &a,&b);
if (b >= 30) {
printf("%d %d", a, (b - 30));
}
else if(b < 30) {
if(a<=0) {
printf("%d %d",(a+23),(b+30));
}
else {
printf ("%d %d", (a - 1), +(b + 30));
}
}
return 0;
}
/*
#include <stdio.h>
int main()
{
int a;
scanf("%d", &a);
if (a % 10 == 1 && a != 11)
{
printf("%dst", a);
}
else if (a % 10 == 2 && a!=12)
{
printf("%dnd", a);
}
else if (a % 10 == 3 && a!= 13)
{
printf ("%drd", a);
}
else
{
printf("%dth", a);
}
}
*//*
#include <stdio.h>
int main() {
double a, b, aa, bb;
scanf ("%lf %lf", &a, &b);
aa = (a - 100) * 0.9;
bb = (b - aa) * 100 / aa;
if (bb <= 10) {
printf("정상");
} else if (bb <= 20) {
printf ("과체중");
} else {
printf("비만");
}
return 0;
}*/