readlines.each{|line|
  yyyy,mm,dd = line.split.map(&:to_i)
  if yyyy < 1868 || (yyyy == 1868 && (mm < 9 || (mm == 9 && dd < 8)))
    puts "pre-meiji"
  elsif yyyy < 1912 || (yyyy == 1912 && (mm < 7 || (mm == 7 && dd < 30)))
    puts "meiji #{yyyy-1867} #{mm} #{dd}"
  elsif yyyy < 1926 || (yyyy == 1926 && (mm < 12 || (mm == 12 && dd < 25)))
    puts "taisho #{yyyy-1911} #{mm} #{dd}"
  elsif yyyy < 1989 || (yyyy == 1989 && (mm < 1 || (mm == 1 && dd < 8)))
    puts "showa #{yyyy-1925} #{mm} #{dd}"
  else
    puts "heisei #{yyyy-1988} #{mm} #{dd}"
  end
}