import java.io.*;
import java.util.*;
class wareki_seireki {
public static void main
(String args
[]) {
int x_nen, y_tuki, z_hi, r_all;
//System.out.print("input integer: ");
for(;;){
try{
if(buf==null){break;}
if(buf.length()<8){continue;}
String nen
= buf.
substring(0,
4); String tuki
= buf.
substring(4,
6); String hi
= buf.
substring(6,
8); String all
= buf.
substring(0,
8);
x_nen = 0;
y_tuki=0;
z_hi=0;
r_all = 0;
}
try{
c.clear();
c.setLenient(false);
err="年";
c.getTime();
err="月";
c.getTime();
err="日";
c.getTime();
err="";
}
System.
out.
println("不正な"+err
+": "+r_all
); continue;
}
if(18691023<=r_all && 19120729>=r_all && 01<=y_tuki && 13>y_tuki && 01<=z_hi && 32>z_hi) {
int meiji=x_nen-1868;
System.
out.
println(("明治")+meiji
+("年")+y_tuki
+("月")+(++z_hi
)+("日")); }
if(19120730<=r_all && 19261224>=r_all && 01<=y_tuki && 13>y_tuki && 01<=z_hi && 32>z_hi) {
int taisyo=x_nen-1911;
System.
out.
println(("大正")+taisyo
+("年")+y_tuki
+("月")+z_hi
+("日")); }
if(19261225<=r_all && 19890107>=r_all && 01<=y_tuki && 13>y_tuki && 01<=z_hi && 32>z_hi) {
int syowa=x_nen-1925;
System.
out.
println(("昭和")+syowa
+("年")+y_tuki
+("月")+z_hi
+("日")); }
if(19890108<=r_all && 20121231>=r_all && 01<=y_tuki && 13>y_tuki && 01<=z_hi && 32>z_hi) {
int heisei=x_nen-1988;
System.
out.
println(("平成")+heisei
+("年")+y_tuki
+("月")+z_hi
+("日")); }
}
}
}
CmltcG9ydCBqYXZhLmlvLio7IAppbXBvcnQgamF2YS51dGlsLio7IApjbGFzcyB3YXJla2lfc2VpcmVraSB7CgkKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZyBhcmdzW10pCiAgICB7CiAgICAgICAgICAgIGludCB4X25lbiwgeV90dWtpLCB6X2hpLCByX2FsbDsKICAKICAgICAgICAgICAgLy9TeXN0ZW0ub3V0LnByaW50KCJpbnB1dCBpbnRlZ2VyOiAiKTsKICAgICAgICAgICAgSW5wdXRTdHJlYW1SZWFkZXIgaXNyID0gbmV3IElucHV0U3RyZWFtUmVhZGVyKFN5c3RlbS5pbik7CiAgICAgICAgICAgIEJ1ZmZlcmVkUmVhZGVyIGJyID0gbmV3IEJ1ZmZlcmVkUmVhZGVyKGlzcik7CiAgICAgICAgICAgIGZvcig7Oyl7CiAgICAgICAgICAgIHRyeXsKICAgICAgICAgICAgCQogICAgICAgICAgICAJU3RyaW5nIGJ1ZiA9IGJyLnJlYWRMaW5lKCk7IAogICAgICAgICAgICAJaWYoYnVmPT1udWxsKXticmVhazt9CiAgICAgICAgICAgIAlpZihidWYubGVuZ3RoKCk8OCl7Y29udGludWU7fQogICAgICAgICAgICAJU3RyaW5nIG5lbiA9IGJ1Zi5zdWJzdHJpbmcoMCw0KTsKICAgICAgICAgICAgCVN0cmluZyB0dWtpID0gYnVmLnN1YnN0cmluZyg0LDYpOwogICAgICAgICAgICAJU3RyaW5nIGhpID0gYnVmLnN1YnN0cmluZyg2LDgpOwogICAgICAgICAgICAJU3RyaW5nIGFsbCA9IGJ1Zi5zdWJzdHJpbmcoMCw4KTsKICAgICAgICAgICAgCQogICAgICAgICAgICAJeF9uZW4gPSBJbnRlZ2VyLnBhcnNlSW50KG5lbik7IAogICAgICAgICAgICAJeV90dWtpID0gSW50ZWdlci5wYXJzZUludCh0dWtpKTsgCiAgICAgICAgICAgIAl6X2hpID0gSW50ZWdlci5wYXJzZUludChoaSk7IAogICAgICAgICAgICAJcl9hbGwgPSBJbnRlZ2VyLnBhcnNlSW50KGFsbCk7CiAgICAgICAgICAgIAkgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICB9Y2F0Y2goRXhjZXB0aW9uIGUpeyAKICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgeF9uZW4gPSAwOwogICAgICAgICAgICAgICAgICAgIHlfdHVraT0wOwogICAgICAgICAgICAgICAgICAgIHpfaGk9MDsKICAgICAgICAgICAgICAgICAgICByX2FsbCA9IDA7CiAgICAgICAgICAgIH0KICAgICAgICAKICAgICAgICAgICAgU3RyaW5nIGVycj0iIjsKICAgICAgICAgICAgdHJ5ewogICAgICAgICAgICAgICAgQ2FsZW5kYXIgYyA9IENhbGVuZGFyLmdldEluc3RhbmNlKCk7CiAgICAgICAgICAgICAgICBjLmNsZWFyKCk7CiAgICAgICAgICAgICAgICBjLnNldExlbmllbnQoZmFsc2UpOwogICAgICAgICAgICAgICAgZXJyPSLlubQiOwogICAgICAgICAgICAgICAgYy5zZXQoQ2FsZW5kYXIuWUVBUiwgeF9uZW4pOwogICAgICAgICAgICAgICAgYy5nZXRUaW1lKCk7CiAgICAgICAgICAgICAgICBlcnI9IuaciCI7CiAgICAgICAgICAgICAgICBjLnNldChDYWxlbmRhci5NT05USCwgeV90dWtpLTEpOwogICAgICAgICAgICAgICAgYy5nZXRUaW1lKCk7CiAgICAgICAgICAgICAgICBlcnI9IuaXpSI7CiAgICAgICAgICAgICAgICBjLnNldChDYWxlbmRhci5EQVRFLCB6X2hpKTsKICAgICAgICAgICAgICAgIGMuZ2V0VGltZSgpOwogICAgICAgICAgICAgICAgZXJyPSIiOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoKElsbGVnYWxBcmd1bWVudEV4Y2VwdGlvbiBleCl7CiAgICAgICAgICAgIAlTeXN0ZW0ub3V0LnByaW50bG4oIuS4jeato+OBqiIrZXJyKyI6ICIrcl9hbGwpOwogICAgICAgICAgICAJY29udGludWU7CiAgICAgICAgICAgIH0KCiAgICAgICAgCiAgICAgICAgICAgIGlmKDE4NjkxMDIzPD1yX2FsbCAmJiAxOTEyMDcyOT49cl9hbGwgICYmIDAxPD15X3R1a2kgJiYgMTM+eV90dWtpICYmIDAxPD16X2hpICYmIDMyPnpfaGkpIHsKICAgICAgICAJCWludCBtZWlqaT14X25lbi0xODY4OwogICAgICAgIAkJU3lzdGVtLm91dC5wcmludGxuKCgi5piO5rK7IikrbWVpamkrKCLlubQiKSt5X3R1a2krKCLmnIgiKSsoKyt6X2hpKSsoIuaXpSIpKTsJCiAgICAgICAgICAgfQogICAgICAgIAkKICAgICAgICAJaWYoMTkxMjA3MzA8PXJfYWxsICYmIDE5MjYxMjI0Pj1yX2FsbCAgJiYgMDE8PXlfdHVraSAmJiAxMz55X3R1a2kgJiYgMDE8PXpfaGkgJiYgMzI+el9oaSkgewogICAgICAgIAkJaW50IHRhaXN5bz14X25lbi0xOTExOwogICAgICAgIAkJU3lzdGVtLm91dC5wcmludGxuKCgi5aSn5q2jIikrdGFpc3lvKygi5bm0IikreV90dWtpKygi5pyIIikrel9oaSsoIuaXpSIpKTsJCiAgICAgICAgCX0KICAgICAgICAJCiAgICAgICAgCWlmKDE5MjYxMjI1PD1yX2FsbCAmJiAxOTg5MDEwNz49cl9hbGwgICYmIDAxPD15X3R1a2kgJiYgMTM+eV90dWtpICYmIDAxPD16X2hpICYmIDMyPnpfaGkpIHsKICAgICAgICAJCWludCBzeW93YT14X25lbi0xOTI1OwogICAgICAgIAkJU3lzdGVtLm91dC5wcmludGxuKCgi5pit5ZKMIikrc3lvd2ErKCLlubQiKSt5X3R1a2krKCLmnIgiKSt6X2hpKygi5pelIikpOwkKICAgICAgICAJfQogICAgICAgIAkKICAgICAgICAJaWYoMTk4OTAxMDg8PXJfYWxsICYmIDIwMTIxMjMxPj1yX2FsbCAgJiYgMDE8PXlfdHVraSAmJiAxMz55X3R1a2kgJiYgMDE8PXpfaGkgJiYgMzI+el9oaSkgewogICAgICAgIAkJaW50IGhlaXNlaT14X25lbi0xOTg4OwogICAgICAgIAkJU3lzdGVtLm91dC5wcmludGxuKCgi5bmz5oiQIikraGVpc2VpKygi5bm0IikreV90dWtpKygi5pyIIikrel9oaSsoIuaXpSIpKTsJCiAgICAgICAgCX0KICAgICAgCiAgICAgCiAgICAgICAgICAgIH0KICAgIH0KCQogICAgfQo=