require 'date'
meiji = Date.new(1868, 9, 8)
taisho = Date.new(1912, 7, 30)
showa = Date.new(1926, 12, 25)
heisei = Date.new(1989, 1, 8)
years_stan = [1867, 1911, 1925, 1988]
readlines.each do |date|
  year, month, day = date.chomp.split.map(&:to_i)
  today = Date.new(year, month, day)
  if today - meiji < 0
    puts "pre-meiji"
  elsif today - taisho < 0
    puts "meiji #{year - years_stan[0]} #{month} #{day}"
  elsif today - showa < 0
    puts "taisho #{year - years_stan[1]} #{month} #{day}"
  elsif today - heisei < 0
    puts "showa #{year - years_stan[2]} #{month} #{day}"
  else
    puts "heisei #{year - years_stan[3]} #{month} #{day}"
  end
end