#include using namespace std; typedef long long ll; #define pb push_back #define rep(i,n) for(int i=0;i<(n);++i) int main(){ cin.tie(0); ios::sync_with_stdio(false); int n,h,m,t;cin >> n >> h >> m >> t; int m1=(n-1)*t; int h1=(m1/60)%24; m1%=60; int ansm,ansh; if(m1+m>=60){ h1++; } ansm=(m1+m)%60; ansh=(h1+h)%24; cout << ansh << endl; cout << ansm << endl; }