#!ruby -pal
t=[[1989,1,7],[1926,12,24],[1912,7,29],[1868,9,7],[1]]
s=["heisei"+d=" %d"*3,"showa"+d,"taisho"+d,"meiji"+d,"pre-meiji"]
i=t.index{|l|Time.gm(*l)<Time.gm(*$F)}
$F[0]=$F[0].to_i-t[i][0]+1
$_=s[i]%$F