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]);
int C = Integer.parseInt(br.readLine());
int D = B+C;
while(D>=60){
D-=60;
A+=1;
if(A==24){
A = 0;
}
}
bw.write(A + " " + D);
bw.flush();
bw.close();
}
}