main = do
  ss <- getContents
  mapM_ func $ map words $ lines ss

func s = do
  putStrLn $ era s

era s
  | i < [1868,9,8]    = "pre-meiji"
  | i < [1912,7,30]   = ("meiji " ++) $ unwords $ map show $ tra i 1867
  | i < [1926,12,25]  = ("taisho " ++) $ unwords $ map show $ tra i 1911
  | i < [1989,1,8]    = ("showa " ++) $ unwords $ map show $ tra i 1925
  | otherwise         = ("heisei " ++) $ unwords $ map show $ tra i 1988
  where i = map read s
        tra s num = ((head s) - num) : head (tail s) : tail (tail s)