import sys
import bisect

while True:
    n, m = map(int, sys.stdin.readline().split())
    if n == 0:
        break
    date = []
    for i in xrange(n):
        input = raw_input().split()
        name = input[0]
        end = int(input[2])
        start = end - int(input[1]) + 1
        date.append((start, end, name))
    for i in xrange(m):
        year = int(raw_input())
        for j in date:
            if j[0] <= year <= j[1]:
                print j[2], year - j[0] + 1
                break
        else:
            print 'Unknown'
