import std.stdio; import std.conv; import std.string; import std.algorithm; // solve ----------------------- void solve(){ auto nhmt = readln.strip.split.map!(to!long); auto awake = nhmt[1] * 60 + nhmt[2]; auto past = nhmt[3] * (nhmt[0] - 1); awake += past; writeln(( awake / 60) % 24); writeln( awake % 60 ); } // main ------------------------ void main(){ solve(); }