main = interact $ unlines . map (show' . era_name . words) . lines
 where show' = maybe "pre-meiji" unwords

era_name [y,m,d]
 | ymd < "1868 9 8" = Nothing
 | ymd < "1912 730" = Just ["meiji", show ((read y)-1867), m, d]
 | ymd < "19261225" = Just ["taisho", show ((read y)-1911), m, d]
 | ymd < "1989 1 8" = Just ["showa", show ((read y)-1925), m, d]
 | otherwise = Just ["heisei", show ((read y)-1988), m, d]
 where
  ymd = concat [justifyr 4 y, justifyr 2 m, justifyr 2 d]
  justifyr n = reverse . take n . (++ (replicate n ' ')) . reverse