#include using namespace std; int main(){ int a,b,c,d;cin>>a>>b>>c>>d; c+= (a-1)*d; d += c/60; cout << d << endl; cout << c%60 << endl; }