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<string>
#include<map>
using namespace std;
int main()
{
  while(true){
    int N,Q;
    cin >> N >> Q;
    if(N==0&&Q==0)break;
    map<long long int,string> M;
    for(int i = 0; i < N; ++i){
      string era;
      long long int now;
      long long int y;
      cin >> era >> now >> y;
      M[y-now+1]=era;
      M[y]=era;
    }
    for(int i = 0; i < Q; ++i){
      long long int y;
      long long int res=-1;
      string res_era;
      cin >> y;
      map<long long int,string>::iterator itm = M.lower_bound(y);
      if(itm==M.end())itm=M.begin();
      if(itm!=M.begin()){
	--itm;
      }
      while(true){
	if(itm==M.end())break;
	if(itm->first==y){
	  res = 1;
	  res_era = itm->second;
	  break;
	}
	if(itm->first>y){
	  break;
	}else{
	  map<long long int,string>::iterator itm2 = itm;
	  itm2++;
	  if(itm2==M.end())break;
	  if( y >= itm->first && y <= itm2->first && itm->second == itm2->second ){
	    res = y - itm->first + 1;
	    res_era = itm->second;
	    break;
	  }
	}
	++itm;
      }
      if(res>0){
	cout << res_era << ' ' << res << endl;
      }else{
	cout << "Unknown" << endl;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<string, P> PP;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef vector<PP> Vpp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int main(){
	int n, q;
	while(scanf("%d%d", &n, &q),n||q){
		Vpp vec;
		rep(i,n){
			string str;
			int a,b;
			cin >> str >> a >> b;
			vec.pb(PP(str,P(a,b)));
		}
		rep(i,q){
			int a;
			bool ok = false;
			cin >> a;
			rep(j,n){
				if(vec[j].sec.sec >= a && a+vec[j].sec.fi > vec[j].sec.sec){
					cout << vec[j].fi << " " << a+vec[j].sec.fi-vec[j].sec.sec << endl;
					ok = true;
					break;
				}
			}
			if(!ok) cout << "Unknown" << endl;
		}
	}
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
 
const int INF = 10000000;

int main(){
	int n, m;
	string s;
	int a, b;
	while(cin>>n>>m && n > 0 && m > 0){
		map<int, string> ms;
		map<string, int> me;
		rep(i, n){
			cin>>s>>a>>b;
			ms[b - a + 1] = s;
			me[s] = b;
		}
		rep(i, m){
			cin>>a;
			auto it = ms.upper_bound(a);
			if(it == ms.begin()){
				cout<<"Unknown"<<endl;
				continue;
			}
			--it;
			if(a <= me[it->se]) cout<<it->se<<" "<<a - it->fi + 1<<endl;
			else cout<<"Unknown"<<endl;
		}
	}
	
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
#define P pair<int,int>
int main(){
	int n,m;
while(true){
	cin>>n>>m;
if(n==0&&m==0)break;
vector<pair<P,string> >ta;//西暦、基数、名前の順番で入れる
for(int i=0;i<n;i++){
int a,b;string c;
cin>>c>>a>>b;
ta.push_back(pair<P,string>(P(b,a),c));
}
sort(ta.begin(),ta.end());
for(int izc=0;izc<m;izc++){
int tmp;
cin>>tmp;
bool f=0;
for(int i=0;i<n;i++){
int a=ta[i].first.first,b=ta[i].first.second;
string c=ta[i].second;
if(b-(a-tmp)>=1&&b>=b-(a-tmp)){
cout<<c<<" "<<b-(a-tmp)<<endl;
f=1;
}

}
if(f==0)cout<<"Unknown"<<endl;
}//for
}//while
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		int n, q; scanf("%d %d", &n, &q);
		if (n == 0)break;
		vector<tuple<ll, string, ll>> vp(n);
		for (int i = 0; i < n; i++) {
			string s;
			ll e, w;
			cin >> s >> e >> w;
			vp[i] = make_tuple(w, s, e);
		}
		sort(vp.begin(), vp.end());
		while (q--) {
			ll t; scanf("%lld", &t);
			auto itr = lower_bound(vp.begin(), vp.end(), make_tuple(t, "", -1));
			if (itr == vp.end()) puts("Unknown");
			else {
				ll e, w;
				string s;
				tie(w, s, e) = *itr;
				ll one = w - (e - 1);
				if (t < one) puts("Unknown");
				else {
					cout << s << " " << (1 + (t - one)) << "\n";
				}
			}
		}
	}
	return 0;

}