Go: package main

import (
	"fmt"
	"sort"
)

type Datum struct {
	EraName      string
	EraBasedYear int64
	WesternYear  int64
}

const Unknown = "Unknown"

func lowerBound(data []*Datum, westernYearBorder int64) int {
	imin := -1
	imax := len(data)
	for imax-imin > 1 {
		imid := (imax + imin) / 2
		if data[imid].WesternYear >= westernYearBorder {
			imax = imid
		} else {
			imin = imid
		}
	}
	return imax
}

func solve(n, q int) {
	data := make([]*Datum, 0, n)
	for index := 0; index < n; index++ {
		datum := Datum{}
		fmt.Scan(&datum.EraName, &datum.EraBasedYear, &datum.WesternYear)
		data = append(data, &datum)
	}
	sort.Slice(data, func(i, j int) bool {
		return data[i].WesternYear < data[j].WesternYear
	})
	for cnt := 0; cnt < q; cnt++ {
		var query int64
		fmt.Scan(&query)
		var index int
		if index = lowerBound(data, query); index == n {
			fmt.Println(Unknown)
			continue
		}
		possibleDatum := data[index]
		if possibleDatum.WesternYear-query > possibleDatum.EraBasedYear-1 {
			fmt.Println(Unknown)
			continue
		}
		ans := possibleDatum.EraBasedYear - (possibleDatum.WesternYear - query)
		fmt.Println(possibleDatum.EraName, ans)
	}
}

func main() {
	for {
		var n, q int
		if fmt.Scan(&n, &q); n == 0 && q == 0 {
			break
		}
		solve(n, q)
	}
}

Python: from bisect import bisect_left


while True:
	N, Q = map(int, input().split(' '))
	if N == 0:
		break

	era = {} # Like {1877: ('Meiji', 10)}

	years = [] # 西暦
	for _ in range(N):
		name, j, w = input().split(' ')
		j, w = int(j), int(w)
		era[w] = (name, j)
		years.append(w)
	years.sort()

	for _ in range(Q):
		q = int(input())
		y = years[bisect_left(years, q)]
		name, length = era[y]
		if q - y + length <= 0:
			print('Unknown')
		else:
			print(name + ' ' + str(q-y+length))

Python: from bisect import bisect_left


while True:
	N, Q = map(int, input().split(' '))
	if N == 0:
		break

	era = {} # Like {1877: ('Meiji', 10)}

	years = [] # 西暦
	for _ in range(N):
		name, j, w = input().split(' ')
		j, w = int(j), int(w)
		era[w] = (name, j)
		years.append(w)
	years.sort()

	for _ in range(Q):
		q = int(input())
		y = years[bisect_left(years, q)]
		name, length = era[y]
		if q - y + length <= 0:
			print('Unknown')
		else:
			print(name + ' ' + str(q-y+length))

Python: #!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve(n,e,q):
    l = set([i for i in q])
    d = defaultdict(lambda : 0)
    for i in range(n):
        n,j,k = e[i]
        j = int(j)
        k = int(k)
        d[k-j+1] += i+1
        d[k+1] -= i+1
        l.add(k-j+1)
        l.add(k+1)
    l = list(l)
    l.sort()
    for i in range(len(l)-1):
        d[l[i+1]] += d[l[i]]
    for i in q:
        j = d[i]
        if j > 0:
            print(e[j-1][0],i-int(e[j-1][2])+int(e[j-1][1]))
        else:
            print("Unknown")
    return

#Solve
if __name__ == "__main__":
    while 1:
        n,Q = LI()
        if n == Q == 0:
            break
        e = [input().split() for i in range(n)]
        q = IR(Q)
        solve(n,e,q)

Python: #Time limit exceedsになるので二分探索法を使う
from bisect import bisect_left


while True:
    n, q = map(int, input().split())
    if n == 0:
        break

    era = {} # {西暦: ('元号', 年)}
    years = [] 
    
    for _ in range(n):
        gengou, wa_year, we_year = input().split()
        wa_year = int(wa_year)
        we_year = int(we_year)
        era[we_year] = (gengou, wa_year)
        years.append(we_year)
    
    years_final = sorted(years) 

    for _ in range(q):
        year1 = int(input())
        temp = bisect_left(years_final, year1)
        
        if temp >= len(years_final):
            print('Unknown')
            continue
            
        year2 = years_final[temp]
        gengou, span = era[year2]
        result = year1 - year2 + span

        if result <= 0:
            print('Unknown')
        else:
            print(gengou, result)

Python: from bisect import bisect_left


while True:
	N, Q = map(int, input().split(' '))
	if N == 0:
		break

	era = {} # Like {1877: ('Meiji', 10)}

	years = [] # 西暦
	for _ in range(N):
		name, j, w = input().split(' ')
		j, w = int(j), int(w)
		era[w] = (name, j)
		years.append(w)
	years.sort()

	for _ in range(Q):
		q = int(input())
		y = years[bisect_left(years, q)]
		name, length = era[y]
		if q - y + length <= 0:
			print('Unknown')
		else:
			print(name + ' ' + str(q-y+length))

Python: while True:
    N, Q = map(int, input().split())
    if not N:
        break
    a = []
    for i in range(N):
        x, y, z = input().split()
        a.append((int(z), int(z) - int(y), x))
    a = list(reversed(sorted(a)))
    for i in range(Q):
        x = int(input())
        for v in a:
            if v[0] >= x and v[1] < x:
                print(v[2], x - v[1])
                break;
        else:
            print('Unknown')

Python: while True:
    inp,oup=map(int,input().split())
    if not inp: 
        break
    dic={}
    for i in range(inp):
        era,num,wes=input().split()
        dic[era] =[int(wes)-int(num)+1, int(wes)]
    for j in range(oup):
        p=int(input())
        for i in dic:
            if dic[i][0]<=p<=dic[i][1]:
                print(i+' '+str(p-dic[i][0]+1))
                break
        else:
             print('Unknown')

Python: while True:
    n, q = map(int, input().split())
    d = {}

    if n == 0 and q == 0:
        break

    for i in range(n):
        era, years, now = input().split()
        begin = int(now) - int(years) + 1
        d[era] = [begin, int(now)]

    for i in range(q):
        year = int(input())
        for e, y in d.items():
            if year >= y[0] and year <= y[1]:
                print(e, year - y[0] + 1)
                break
        else:
            print('Unknown')

Python: while 1:
    n,m=map(int,input().split())
    if n==0:break
    e=['']*n;b=['']*n;w=['']*n
    for i in range(n):e[i],b[i],w[i]=input().split()
    b=list(map(int,b));w=list(map(int,w))
    for _ in range(m):
        q=int(input())
        for i in range(n):
            if w[i]-b[i]<q<=w[i]:print(e[i],b[i]-w[i]+q);break
        else:print('Unknown')

Python: import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def solve(N,Q):
    era = []
    for _ in range(N):
        X = input().split()
        name = X[0]
        y = int(X[1])
        w = int(X[2])
        era.append((w - y + 1,w,name))

    for _ in range(Q):
        flag = False
        y = int(input())
        for a,b,c in era:
            if a <= y <= b:
                flag = True
                ans = (c,y - a + 1)
                break
        if flag:
            print(*ans)
        else:
            print('Unknown')

def main():
    while True:
        N,Q = map(int,input().split())
        if N == 0:
            return
        solve(N,Q)
if __name__ == '__main__':
    main()