import java.util.*; public class Exercise50{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int h = sc.nextInt(); int m = sc.nextInt(); int t = sc.nextInt(); int sum = t * (n - 1) + m; h += sum / 60; m = sum % 60; System.out.println(h); System.out.println(m); } }