gengo = { 
    "meiji"   => 18680908..19120729,
    "taisho"  => 19120730..19261224,
    "showa"   => 19261225..19890107,
    "heisei"  => 19890108..99999999,
}

while gets
    y, m, d = $_.split
    date = sprintf("%4d%02d%02d\n", y, m, d).to_i
    puts "pre-meiji" unless gengo.any? do |g, range|
        if range === date
            gy = (date - range.min) / 10000 + 1 
            puts "#{g} #{gy} #{m} #{d}"
            break true
        end
    end 
end