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