var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
var time=Arr[0]+Arr[1]+Arr[2]+Arr[3];
console.log(Math.floor(time/60));
console.log(time%60);