loop do
    n, q = gets.split.map(&:to_i)
    break if n == 0 && q == 0
    h = Hash.new
    n.times do
        s = gets.split
        t = h[s[0]]
        if !t
            h[s[0]] = [s[2].to_i - s[1].to_i + 1, s[2].to_i]
        else
            h[s[0]] = [s[2].to_i - s[1].to_i + 1, [s[2].to_i, t[1]].max]
        end
    end
    qr = q.times.map{gets.to_i}
    qr.each do |qq|
        bl = false
        h.each do |k,v|
            if qq.between?(v[0],v[1])
                puts "#{k} #{qq - v[0] + 1}"
                bl = true
                break
            end
        end
        puts "Unknown" if !bl
    end
end