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<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<unsigned int,pair<unsigned int,string> > P;
vector<P> que;
int main(){
	while(cin>>N>>Q,N||Q){
		que.clear();
		unsigned int A[1010]={0};

		for(int i = 0;i < N;i++){
			string str;
			unsigned 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++){
			unsigned wes;
			cin>>wes;
			unsigned 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 <cstring>
#include <cstdio>

using namespace std;
const int Maxn = 1010;
struct Era
{
	char name[20];
	int n;
	int year;
}era[Maxn];
int n, m;

void solve(int year)
{
	int ret = -1;
	for (int i = 0; i < n; ++i)
	{
		if (era[i].year < year) continue;
		if (era[i].year - era[i].n < year)
		{
			if (ret == -1) ret = i;
			else ret = -2;
		
		}
	}
	if (ret < 0) 
		puts("Unkonwn");
	else 	printf("%s %d\n", era[ret].name, era[ret].n + year - era[ret].year);
			
	
}
int main()
{
	while (scanf("%d%d", &n, &m) != EOF)
	{
		if (n == 0) break;
		for (int i = 0; i < n; ++i)
			scanf("%s%d%d", era[i].name, &era[i].n, &era[i].year);
		for (int i = 0; i < m; ++i)
		{
			int y;
			scanf("%d", &y);
			solve(y);
		}
		
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

typedef pair<string, int> P;
typedef pair<int, P> P2;

int main(){
	
	int N, Q;
	
	while(true){
		cin >> N >> Q;
		
		if(N == 0 && Q == 0){
			break;
		}
		
		map<int, P> m;
		
		for(int i = 0; i < N; i++){
			string str;
			int num1, num2;
			cin >> str >> num1 >> num2;
			P p;
			p.first = str;
			p.second = num1;
			m[num2] = p;
		}
		
		for(int i = 0; i < Q; i++){
			int num;
			cin >> num;
			map<int, P>::iterator ite;
			ite = m.lower_bound(num);
			if(ite == m.end()){
				cout << "Unknown" << endl;
				continue;
			}
			int num2 = ite->first;
			string str = ite->second.first;
			int num1 = ite->second.second;
			if(num2 - num <= num1 - 1){
				cout << str << " " << num1 - (num2 - num) << endl;
			}else{
				cout << "Unknown" << endl;
			}
		}
		
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;


int main(void) {
  int n, q;
  while (cin >> n >> q, n) {
    vector< pair<pii, string> > v;
    for (int i = 0; i < n; i++) {
      string name;
      int a, b;
      cin >> name >> a >> b;
      v.push_back(make_pair(pii(b - a, b), name));
    }
    sort(v.begin(), v.end());

    for (int i = 0; i < q; i++) {
      int y;
      cin >> y;

      int l = 0, r = n;
      while (r - l > 0) {
        int m = (l + r) / 2;
        int a = v[m].first.first, b = v[m].first.second;
        if (y <= a) r = m;
        else if (y > b) l = m + 1;
        else l = m, r = m;
      }

      if (l < n && v[l].first.first < y && v[l].first.second) {
        cout << v[l].second << " " << y - v[l].first.first << endl;
      } else {
        cout << "Unknown\n";
      }
    }
  }

  return 0;
}

C++: #include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define F first
#define S second
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n, m;

main(){
	while(cin >> n >> m, n){
		vector< pair<string, pii> > names(n);
		REP(i, n){
			cin >> names[i].F >> names[i].S.F >> names[i].S.S;
			names[i].S.F = names[i].S.S - names[i].S.F;
		}
		REP(i, m){
			int y, f=0;
			cin >> y;
			REP(j, n){
				if(names[j].S.F < y && y <= names[j].S.S){
					cout << names[j].F << " " << y - names[j].S.F << endl;
					f = 1;
					break;
				}
			}
			if(!f) cout << "Unknown" << endl;
		}
	}
	return 0;
}