package src.chap_02;
import java.util.Scanner;
public class backjun {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int h = sc.nextInt();
int m = sc.nextInt();
int c = sc.nextInt();
int total = 60 * h + m + c;
if (total >= 1440){
total -= 1440;
h = total / 60;
m = total % 60;
System.out.println(h + " " + m );
}else{
h = total / 60;
m = total % 60;
System.out.println(h + " " + m );
}
}
}