require 'date'

MEIJI = [Date::new(1868, 9, 8), Date::new(1912, 7, 29)]
TAISHO = [Date::new(1912, 7, 30), Date::new(1926, 12, 24)]
SHOWA = [Date::new(1926, 12, 25), Date::new(1989, 1, 7)]
HEISEI = Date::new(1989, 1, 8)

while s = gets
  s = s.chomp
  
  d = Date::strptime(s, "%Y %m %d")

  if HEISEI <= d then
    puts "heisei %d %d %d" % [d.year-HEISEI.year+1, d.month, d.day]
  elsif SHOWA[0] <= d && d <= SHOWA[1] then
    puts "showa %d %d %d" % [d.year-SHOWA[0].year+1, d.month, d.day]
  elsif TAISHO[0] <= d && d <= TAISHO[1] then
    puts "taisho %d %d %d" % [d.year-TAISHO[0].year+1, d.month, d.day]
  elsif MEIJI[0] <= d && d <= MEIJI[1] then
    puts "meiji %d %d %d" % [d.year-MEIJI[0].year+1, d.month, d.day]
  else
    puts "pre-meiji"
  end
end