#include <iostream>
#include <cstdio>
using namespace std;
class MyTime {
private:
int hour;
int min;
int sec;
public:
void SetTime(int h, int m, int s);
void print_12();
void print_24();
};
int main() {
int h, m, s;
cin >> h >> m >> s;
MyTime clock;
clock.SetTime(h, m, s);
clock.print_12();
clock.print_24();
return 0;
}
void MyTime::SetTime(int h, int m, int s) {
hour = h;
min = m;
sec = s;
}
void MyTime::print_12() {
if (hour >= 12) //printf可以换成cout,但printf确实方便
printf("%02d:%02d:%02d PM\n", hour % 12, min, sec);
else
printf("%02d:%02d:%02d AM\n", hour, min, sec);
}
void MyTime::print_24() {
printf("%02d:%02d:%02d\n", hour, min, sec);
}
//格式问题,时分秒都要不足两位用0补齐