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