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