const n = require("fs").readFileSync(0, "utf-8").toString().split("\n");
const [h, m] = n[0].split(" ").map(Number);
const d = parseInt(n[1]);
const t = h*60 + m + d + 1440;
console.log("%d %d",Math.floor(t/60)%24, t%60);