split :: String -> String -> [String]
split _ "" = [""]
split t (s:sr)
  |t == [s] = [] : (split t sr)
  |otherwise = (s : (head (split t sr))) : (tail (split t sr))

data Date = Date {year :: Int, month :: Int, day :: Int}

instance Eq Date where
  a == b = (year a == year b) && (month a == month b) && (day a == day b)

instance Ord Date where
  compare a b = ((year a) * 365 + (month a) * 31 + (day a)) `compare` ((year b) * 365 + (month b) * 31 + (day b))

meiji = Date 1868 9 8
taisho = Date 1912 7 30
showa = Date 1926 12 25
heisei = Date 1989 1 8

gengo :: Date -> String
gengo d
  |d < meiji = "pre-meiji" ++ "\n"
  |d < taisho = "meiji " ++ (show ((year d) - (year meiji) + 1)) ++ " " ++ (show $ month d) ++ " " ++ (show $ day d) ++ "\n"
  |d < showa = "taisho " ++ (show ((year d) - (year taisho) + 1)) ++ " " ++ (show $ month d) ++ " " ++ (show $ day d) ++ "\n"
  |d < heisei = "showa " ++ (show ((year d) - (year showa) + 1)) ++ " " ++ (show $ month d) ++ " " ++ (show $ day d) ++ "\n"
  |otherwise = "heisei " ++ (show ((year d) - (year heisei) + 1)) ++ " " ++ (show $ month d) ++ " " ++ (show $ day d) ++ "\n"

main = do
  input <- getContents
  mapM_ putStr $ map gengo $ map (((\[y, m, d] -> Date (read y) (read m) (read d)) .) (split " ")) $ lines input