#include #include #include #include #include #include #include using namespace std; int a, b; string s; string calc(int x) { if (x <= 9) return "0" + to_string(x); return to_string(x); } int main() { cin >> a >> b >> s; int val1 = s[4] - 48; if (s.size() >= 6 && '0' <= s[5] && s[5] <= '9') val1 = val1 * 10 + s[5] - 48; val1 *= 10; if (s.size() >= 7 && '0' <= s[6] && s[6] <= '9') val1 += s[6] - 48; if (s.size() >= 8 && '0' <= s[7] && s[7] <= '9') val1 += s[7] - 48; val1 *= 6; if (s[3] == '-') val1 = -val1; int res = (a * 60 + b + val1 + 1440 + 900) % 1440; cout << calc(res / 60) << ":" << calc(res % 60) << endl; return 0; }