array=[]
while gets
    array=$_.chomp.split(nil).map(&:to_i)
    time=Time.mktime(array[0],array[1],array[2])
      case
        when time<Time.mktime(1868,9,8)
            puts "pre-meiji"
        when time<Time.mktime(1912,7,30)
            puts"meiji #{array[0]-1868+1} #{array[1]} #{array[2]}"
        when time<Time.mktime(1926,12,25)
            puts"taisho #{array[0]-1912+1} #{array[1]} #{array[2]}"
        when time<Time.mktime(1989,1,8)
            puts"showa #{array[0]-1926+1} #{array[1]} #{array[2]}"
        else
            puts"heisei #{array[0]-1989+1} #{array[1]} #{array[2]}"
    end
end