#include <iostream>
using namespace std;
class Time
{
int hour;
int minute;
int second;
public:
void init(int h, int m, int s)
{
hour = h;
minute = m;
second = s;
}
void add(int num)
{
second = second + num;
if (second >= 60)
{
minute += second / 60;
second = second % 60;
}
if (minute >= 60)
{
hour += minute / 60;
minute = minute % 60;
}
if (hour >= 24)
{
hour = hour % 24;
}
}
void print()
{
cout << hour << " " << minute << " " << second;
}
};
int main()
{
int h, m, s;
cin >> h >> m >> s;
int num;
cin >> num;
Time time;
time.init(h, m, s);
time.add(num);
time.print();
return 0;
}