#define _GLIBCXX_DEBUG #define ll long long #include using namespace std; using Graph = vector>; void print(auto a){ cout << a; } void printL(auto a){ cout << a << endl; } void fix(int n){ cout << fixed << setprecision(n); } void Nemu(ll a, ll b, ll c, ll d){ ll e = b*60+c + (a-1)*d; e %= 1440; printL(e/60); printL(e%60); } int main(){ ll N, H, M, T; cin >> N >> H >> M >> T; Nemu(N, H, M, T); }