while gets
  y,m,d=$_.split.map(&:to_s)
  num=(y+format("%02d",m)+format("%02d",d)).to_i
  if num < 18680908 then puts "pre-meiji"
  else
    case
    when num < 19120730 then era = "meiji "+(y.to_i-(num%10000 < 908 ? 1868 : 1867)).to_s
    when num < 19261225 then era = "taisho "+(y.to_i-(num%10000 < 730 ? 1912 : 1911)).to_s
    when num < 19890108 then era = "showa "+(y.to_i-(num%10000 < 1225 ? 1926 : 1925)).to_s
    else era="heisei "+(y.to_i-(num%10000 < 108 ? 1989 : 1988)).to_s
    end
    puts "#{era} #{m} #{d}"
  end
end