readlines.each do |l|
  y,m,d = l.split.map(&:to_i)
  t = Time.new(y,m,d)
  puts case
  when t<Time.new(1868,9,8); "pre-meiji"
  when t<Time.new(1912,7,30); "meiji #{y-1867} #{m} #{d}"
  when t<Time.new(1926,12,25); "taisho #{y-1911} #{m} #{d}"
  when t<Time.new(1989,1,8); "showa #{y-1925} #{m} #{d}"
  else "heisei #{y-1988} #{m} #{d}"
  end
end