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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,Q;cin>>N>>Q;
        if(N+Q==0) break;
        vector<string> A(N);
        vector<int> S(N),T(N);
        
        for(int i=0;i<N;i++){
            cin>>A[i];
            int a,b;cin>>a>>b;
            S[i]=b-a;
            T[i]=b;
        }
        
        for(int i=0;i<Q;i++){
            int a;cin>>a;
            bool ok=false;
            for(int j=0;j<N;j++){
                if(S[j]<a&&a<=T[j]){
                    cout<<A[j]<<" "<<a-S[j]<<endl;
                    ok=true;
                }
            }
            if(!ok) cout<<"Unknown"<<endl;
        }
    }
    
}

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;
	long long int nu, ad;
	
	bool operator<(const ye& a) const{
		if(ad != a.ad) return ad < a.ad;
	}
};

int main(){
	long long 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<a.size();i++){
			cout << a[i].ad << " ";
		}
		cout << endl;*/
		
		for(i=0;i<q;i++){
			cin >> x;
			int z = 0;
			for(j=a.size()-1;j>=0;j--){
				if(x <= a[j].ad){
					if(a[j].nu - (a[j].ad - x) > 0){
						ans.ad=x;
						ans.nu=a[j].nu - (a[j].ad - x);
						ans.ge=a[j].ge;
						z++;
					}
				}
			}
			if(z==1) cout << ans.ge << " " << ans.nu << endl;
			else cout << "Unknown" << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main(){
	while(1){
		int n,q;
		cin >> n >> q;
		if(n == 0 && q == 0) break;
		string en[10000];
		int es[10000],ee[10000];
		for(int i = 0;i < n;i++){
			string ten;
			int eb,wy;
			cin >> ten >> eb >> wy;
			en[i] = ten;
			es[i] = wy - eb + 1;
			ee[i] = wy;
		}
		for(int i = 0;i < q;i++){
			int qer;
			cin >> qer;
			
			string nengo;
			int year = 0;
			bool flag = false;
			
			for(int j = 0;j < n;j++){
				if(es[j] <= qer && qer <= ee[j]){
					nengo = en[j];
					year = qer - es[j] + 1;
					flag = true;
				}
			}
			
			if(flag){
				cout << nengo << " " << year << 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 main(){
	while(cin>>N>>Q,N||Q){
		que.clear();
		int A[1010]={0};

		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>
#include <string>
#include <algorithm>

using namespace std;

typedef struct names {
	string en;
	int eby;
	int wy;
};

/*
void sort(names array[], int S) {
	int sorted, last;
	int i;
	names temp;

	sorted = S;
	while(sorted) {
		last = 0;
		for(i = 0; i < sorted - 1; i++) {
			if(array[i].wy > array[i + 1].wy) {
				temp = array[i];
				array[i] = array[i + 1];
				array[i + 1] = temp;
				last = i + 1;
			}
		}

		sorted = last;
	}
}
*/

bool comp(names A, names B) {
	return A.wy < B.wy;
}

int main(void) {
	int N, Q;
	names data[1024];
	int query;
	int next;

	while(cin >> N >> Q, N != 0 || Q != 0) {
		for(int i = 0; i < N; i++)
			cin >> data[i].en >> data[i].eby >> data[i].wy;
		sort(data, data + N, comp);
		
		for(int i = 0; i < Q; i++) {
			cin >> query;
			for(next = 0; query > data[next].wy && next < N; next++);
			if(next == N) {
				cout << "Unknown" << endl;
				continue;
			}

			if(data[next].eby + query - data[next].wy > 0)
				cout << data[next].en << " " << data[next].eby + query - data[next].wy << endl;
			else
				cout << "Unknown hoge" << endl;
		}
	}
}

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

using namespace std;

#define FOR(i, a, n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define DMP(x) cerr << #x << " = " << (x) << endl;
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __ LINE__ << ") " << " " << __FILE__ << endl;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

inline bool is_in(const ll y, const pll p) {
    return p.first <= y && y <= p.second;
}

int main() {
    while(true) {
        int n, q;
        cin >> n >> q;
        if(n == 0 && q == 0) break;
        unordered_map<string, pll> hs;
        REP(i, n) {
            string en;
            ll ey, wy;
            cin >> en >> ey >> wy;
            hs[en] = make_pair(wy - ey + 1, wy);
        }
        REP(i, q) {
            ll qy;
            cin >> qy;
            bool find_flg = false;
            for(auto v : hs) {
                if(is_in(qy, v.second)) {
                    cout << v.first << " " << qy - v.second.first + 1 << endl;
                    find_flg = true;
                    break;
                }
            }
            if(!find_flg) cout << "Unknown" << endl;
        }
    }
    return 0;
}