readlines.each{|line|
  yyyy,mm,dd = line.split.map(&:to_i)
  date = "%04d%02d%02d" % [yyyy,mm,dd]
  date = date.to_i
  if date < 18680908
    puts "pre-meiji"
  elsif date < 19120730
    puts "meiji #{yyyy-1867} #{mm} #{dd}"
  elsif date < 19261225
    puts "taisho #{yyyy-1911} #{mm} #{dd}"
  elsif date < 19890108
    puts "showa #{yyyy-1925} #{mm} #{dd}"
  else
    puts "heisei #{yyyy-1988} #{mm} #{dd}"
  end
}