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)
	}
}

C++: #define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) return;
		vector<tuple<int,string,int>> inputs;
		REP(i, n) {
			string a;
			cin >> a;
			int b, c;
			cin >> b >> c;
			c -= b - 1;
			inputs.push_back(make_tuple(c, a, b));
		}
		sort(ALL(inputs));
		REP(i, m) {
			int a;
			cin >> a;
			int ok = 0;
			for (int q = inputs.size() - 1; q >= 0; --q) {
				if (get<0>(inputs[q]) <= a&&a - get<0>(inputs[q]) + 1 <= get<2>(inputs[q])) {
					cout << get<1>(inputs[q]) << " " << a - get<0>(inputs[q]) + 1 << endl;
					ok = 1;
					break;
				}
			}
			if (ok == 0) {
				cout << "Unknown" << endl;
			}
		}
	}
}
#undef int
int main() {
	init();
	solve();
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n,q;
	while(scanf("%d%d",&n,&q),n){
		map<int,string>mp;
		rep(i,n){
			string s;
			int j,k;
			cin>>s>>j>>k;
			mp[k-j]=s;
		}
		rep(i,q){
			int d;scanf("%d",&d);
			if(d<=(*mp.begin()).first){
				puts("Unknown");
				continue;
			}
			auto it=mp.upper_bound(d);it--;
			if((*it).first==d)puts("Unknown");
			else cout<<(*it).second<<' '<<d-(*it).first<<endl;
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <string>

using namespace std;

struct era
{
	int s;
	int t;
	string era_name;
};

int main(void)
{
	int n,q;
	string name;
	int jyear,wyear;
	int year;
	int i1,i2;

	while(1){
		cin>>n>>q;
		if(n+q==0) break;

		vector<era> v(n);

		for(i1=0;i1<n;i1++){
			cin>>name>>jyear>>wyear;
			v[i1].s=wyear-jyear+1;
			v[i1].t=wyear;
			v[i1].era_name=name;
		}
		for(i1=0;i1<q;i1++){
			cin>>year;
			for(i2=0;i2<v.size();i2++){
				if(v[i2].s<=year && year<=v[i2].t){
					cout<<v[i2].era_name<<" "<<year-v[i2].s+1<<endl;
					break;
				}
			}
			if(i2==v.size()){
				cout<<"Unknown"<<endl;
			}
		}
	}

	return 0;


}

C++: #include <iostream>
#include <string>
#include <string.h>

using namespace std;

#define MAXN 1001

struct Node
{
    string name;
    int a, b;
}node[MAXN];


int n, m;

void input()
{
    int a, b;

    while (cin >> n >> m)
    {
        if (!n && !m)
        {
            break;
        }

        for (int i = 0; i < n; i++)
        {
            cin >> node[i].name;
            cin >> a >> b;
            node[i].a = b - a + 1;
            node[i].b = b;
        }

        for (int i = 0; i < m; i++)
        {
            cin >> a;
            bool flag = false;

            for (int i = 0; i < n; i++)
            {
                if (node[i].a <= a && a <= node[i].b)
                {
                    cout << node[i].name << ' ' << a - node[i].a + 1<< endl;
                    flag = true;
                    break;
                }
            }

            if (!flag)
            {
                cout << "Unknown" << endl;
            }
        }
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    input();
    return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <cctype>
using namespace std;

#define INF 0x7fffffff
#define eps 1e-12
#define MOD 10000007


struct point
{
    char name[25];
    int a,e;

};
point p[1015];


bool cmp(point a,point b)
{
    return a.a<b.a;
}

int main()
{
    int n,q;
    while(~scanf("%d%d",&n,&q))
    {

        if(n==0&&q==0)
            break;
               int x,y;
        for(int i=0; i<n; i++)
        {
            cin>>p[i].name;
            cin>>x>>y;
            p[i].a=y-x+1;
            p[i].e=y;

        }
        sort(p,p+n,cmp);
        int ss;
        for(int i=0; i<q; i++)
        {
            cin>>ss;
            int id=-1;
            bool k=1;
            for(int j=0; j<n; j++)
                if(p[j].a<=ss&&p[j].e>=ss)
                {
                    id=j;
                    break;
                }
            if(id==-1)
                k=0;
            if(!k)
                puts("Unknown");

            else
                cout<<p[id].name<<" "<<ss-p[id].a+1<<endl;
        }

    }

    return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

#define INF 999999999

struct ye{
	string ge;
	int nu, ad;
	
	bool operator<(const ye& a) const{
		if(ad != a.ad) return ad < a.ad;
	}
};

int main(){
	int i, j, n ,q, x;
	ye ans;
	ye s;
	vector<ye> a;
	while(1){
		cin >> n >> q;
		if(!n) break;
		a.clear();
		for(i=0;i<n;i++){
			cin >> s.ge >> s.nu >> s.ad;
			a.push_back(s);
		}
		sort(a.begin(),a.end());
		for(i=0;i<q;i++){
			cin >> x;
			if(x < a[0].ad){
				if(a[0].nu - (a[0].ad - x) > 0){
					ans.ad=x;
					ans.nu=a[0].nu - (a[0].ad - x);
					ans.ge=a[0].ge;
					cout << ans.ge << " " << ans.nu << endl;
				}
				else cout << "Unknown" << endl;
			}
			else if(a[0].ad <= x && x < a[a.size()-1].ad){
				for(j=1;j<=a.size()-1;j++){
					if(a[j-1].ad == x && x == a[j].ad){
						cout << "Unknown" << endl;
					}
					else if(a[j-1].ad <= x && x < a[j].ad){
						if(a[j].nu - (a[j].ad - x) < 0){
							ans.ad=x;
							ans.nu=a[j-1].nu - (a[j-1].ad - x);
							ans.ge=a[j-1].ge;
							cout << ans.ge << " " << ans.nu << endl;
						}
						else cout << "Unknown" << endl;
					}
				}
			}
			else if(a[a.size()-1].ad <= x){
				ans.ad=x;
				ans.nu=a[a.size()-1].nu - (a[a.size()-1].ad - x);
				ans.ge=a[a.size()-1].ge;
				cout << ans.ge << " " << ans.nu << endl;
			}
		}
	}
	return 0;
}