import std.algorithm; import std.array; import std.conv; import std.math; import std.stdio; import std.string; import std.range; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } void main() { auto xs = readints(); int n = xs[0], h = xs[1], m = xs[2], t = xs[3]; int time = h * 60 + m + (n - 1) * t; writeln((time / 60) % 24, "\n", time % 60); }