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 <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
	_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

struct E {
	string n;
	int b, w;
	bool operator < (const E &a) const { return w < a.w; }
};

int main() {
	for (int N, Q; N = in, Q = in;) {
		vector<E> e(N);
		for (auto &i: e)
			i = {in, in, in};
		sort(begin(e), end(e));
		times(i, Q) {
			int q {in};
			auto r = lower_bound(begin(e), end(e), E{"", 0, q});
			if (r == end(e) || q + r->b <= r->w)
				outl("Unknown");
			else
				outl(r->n, ' ', q + r->b - r->w);
		}
	}
}

C++: #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	while (N) {
		set<pair<int, pair<string, bool>>>s;
		for (int i = 0; i < N; i++) {
			string t;
			int a,b;
			cin >> t >> a >> b;
			s.insert({ b - a + 1,{t,true} });
			s.insert({ b,{t,false} });
		}
		vector<pair<int, pair<string, bool>>>v(s.begin(), s.end());
		v.push_back({ INT_MAX,{"olphe",true} });
		v.push_back({ INT_MAX,{ "olphe",true } });
		for (int i = 0; i < M; i++) {
			int a;
			cin >> a;
			for (int j = 0; j < v.size()/2; j++) {
				if (v[j*2].first > a) {
					cout << "Unknown\n";
					break;
				}
				if (v[j * 2].first <= a&&v[j * 2 + 1].first >= a) {
					cout << v[j * 2].second.first << " " << a - v[j * 2].first + 1 << endl;
					break;
				}
			}
		}
		cin >> N >> M;
	}
	return 0;
}

C++: // AOJ 2242

#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct P {
	string name;
	int s, e;
	P(string name, int s, int e)
	: name(name), s(s), e(e) {}
};
int main(void)
{
	int n, q;
	while (cin >> n >> q, n && q){
		vector <P> data;
		int y1, y2;
		string str;
		for (int i = 0; i < n; i++){
			cin >> str >> y1 >> y2;
			data.push_back(P(str, (y2-y1+1), y2));
		}
		int year;
		for (int i = 0; i < q; i++){
			cin >> year;
			string ret = "Unknown";
			for (int j = 0; j < data.size(); j++){
				if (data[j].s <= year && year <= data[j].e){
					cout << data[j].name << " " << year - data[j].s + 1 << endl;
					goto OK;
				}
			}
			cout << ret << endl;
			OK :;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MAXN 1010
#define FI first
#define SE second
pair<int,pair<int,int> > years[MAXN];
pair<int,int> que[MAXN];
int ans[MAXN],ans2[MAXN];
char name[MAXN][20];
int main()
{
    //freopen("/home/moor/Code/input","r",stdin);
    int n,q;
    while(scanf("%d%d",&n,&q)&&(n||q))
    {
        for(int i=0;i<n;++i)
        {
            int a,b;
            scanf("%s%d%d",name[i],&a,&b);
            years[i].FI=b-a+1,years[i].SE.FI=i,years[i].SE.SE=b;
        }
        sort(years,years+n);
        for(int i=0;i<q;++i)
            scanf("%d",&que[i].FI),que[i].SE=i;
        sort(que,que+q);
        for(int i=0,j=-1;i<q;++i)
        {
            while(j+1<n&&years[j+1].FI<=que[i].FI)  ++j;
            if(j==-1||years[j].SE.SE<que[i].FI)
                ans[que[i].SE]=-1;
            else
                ans[que[i].SE]=years[j].SE.FI,ans2[que[i].SE]=que[i].FI-years[j].FI+1;
        }
        for(int i=0;i<q;++i)
            if(ans[i]==-1)  printf("%s\n","Unknown");
            else    printf("%s %d\n",name[ans[i]],ans2[i]);
    }
    return 0;
}