import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String[] STR = br.readLine().split(" ");
int a = Integer.parseInt(STR[0]);
int b = Integer.parseInt(STR[1]);
if(b<45){
a-=1;
b= 60 + (b-45);
if(a < 0){
a= 23;
}
} else{
b-=45;
}
bw.write(String.valueOf(a)+" ");
bw.write(String.valueOf(b));
bw.flush();
bw.close();
}
}