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++: #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[a.size()-1].ad <= x){
				if(a[a.size()-1].nu - (a[a.size()-1].ad - x) >= 0){
					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;
				}
				else cout << "Unknown" << endl;
			}
			else{
				for(j=1;j<=a.size()-1;j++){
					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;
					}
				}
			}
		}
	}
	return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N,Q;
typedef pair<int,pair<int,string> > P;
vector<P> que;
int A[1000];
int main(){
	while(cin>>N>>Q,N||Q){
		que.clear();
		for(int i = 0;i < N;i++){
			string str;
			int eray,wesy;
			cin>>str>>eray>>wesy;
			que.push_back(P(wesy,mp(eray,str)));
			A[i] = wesy;
		}
		sort(que.begin(),que.end());
		sort(A,A+N);
		for(int i = 0;i<Q;i++){
			int wes;
			cin>>wes;
			int k = lower_bound(A,A+N,wes)-A;
			//cout<<que[k].first-wes<<endl;
			if(que[k].second.first>que[k].first-wes){
				cout <<que[k].second.second<<" "<<que[k].second.first-(que[k].first-wes)<<endl;
			}else{
				cout <<"Unknown"<<endl;
			}
		}
		/*(!que.empty()){
			cout <<que.top().first<<endl;
			que.pop();
		}*/
	}
	return 0;
}

C++: #include<iostream>
#define N 1000
using namespace std;

int main(){
  while(1){
    int n,q,e[N],w[N],que,f;
    string str[N];
    cin>>n>>q;
    if(n+q==0) break;
    for(int i=0;i<n;i++)cin>>str[i]>>e[i]>>w[i];
    for(int i=0;i<q;i++){
      cin>>que,f=0;
      for(int j=0;j<n;j++)if(e[j]-(w[j]-que)>0 && e[j]-(w[j]-que)<=e[j]) cout<<str[j]<<" "<<e[j]-(w[j]-que)<<endl,f=1;
      if(f==0) cout<<"Unknown"<<endl;
    }
  }
  return 0;
}

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 (cin >> n >> q, n) {
		map<int, string>mp;
		map<string, int>m;
		rep(i, n) {
			string s;
			int j, k;
			cin >> s >> j >> k;
			mp[k - j + 1] = s;
			m[s] = j;
		}
		rep(i, q) {
			int d; cin >> d;
			bool flag = false;
			for (auto p : mp) {
				if (0 <= d - p.first&&d - p.first < m[p.second]) {
					flag = true;
					cout << p.second << ' ' << d - p.first + 1 << endl;
					break;
				}
			}
			if (!flag)puts("Unknown");
		}
	}
}