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;

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    for (;;) {
        int n, m;
        cin >> n >> m;
        if (!n)
            break;

        vector<int> tstart(n), tend(n);
        vector<string> tname(n);

        rep(i, 0, n) {
            int l;
            cin >> tname[i] >> l >> tend[i];
            tstart[i] = tend[i] - l + 1;
        }

        rep(i, 0, m) {
            int y;
            cin >> y;
            bool ok = false;
            rep(i, 0, n) {
                if (tstart[i] <= y && y <= tend[i]) {
                    cout << tname[i] << " " << (y - tstart[i] + 1) << endl;
                    ok = true;
                }
            }
            if (!ok)
                cout << "Unknown" << endl;
        }
    }
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	bool operator<(const struct Info &arg) const{
		return base_year < arg.base_year;
	};

	char name[17];
	int base_year,end_year;
};

void func(int N, int Q){
	Info info[N];
	int tmp1,tmp2;

	for(int i = 0; i < N; i++){
		scanf("%s %d %d",info[i].name,&tmp1,&tmp2);
		info[i].base_year = tmp2-tmp1+1;
		info[i].end_year = tmp2;
	}

	sort(info,info+N);

	bool FLG;
	for(int i = 0; i < Q; i++){
		scanf("%d",&tmp1);

		FLG = false;

		for(int k = 0; k <= N-1; k++){
			if(tmp1 >= info[k].base_year && tmp1 <= info[k].end_year){
				printf("%s %d\n",info[k].name,tmp1-info[k].base_year+1);
				FLG = true;
				break;
			}
		}
		if(!FLG)printf("Unknown\n");
	}
}


int main(){

	int N,Q;

	while(true){
		scanf("%d %d",&N,&Q);
		if(N == 0 && Q == 0)break;

		func(N,Q);
	}

	return 0;
}

C++: #include <stdio.h>
#include <string.h>

int main(void){
	int es[1000], eg[1000], eby, wy, n, q, i, j, query;
	char name[1000][18], c;
	while(1){
		scanf("%d%d%*c",&n,&q);
		if(n == 0 && q == 0)
			break;
		for(i = 0;i < n;i++){
			j = 0;
			while((c = getchar()) != ' ')
				name[i][j++] = c;
			name[i][j] = '\0';
			scanf("%d%d%*c",&eby,&eg[i]); // eby <= wy
			eg[i]--;
			es[i] = eg[i] - eby + 1;
		}
		for(i = 0;i < q;i++){
			scanf("%d%*c",&query);
			query--;
			for(j = 0;j < n;j++){
				if(es[j] <= query && query <= eg[j])
					break;
			}
			if(j != n)
				printf("%s %d\n",name[j],query - es[i] + 1);
			else
				printf("Unknown\n");
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
string a[1000];
int tim[1000][2];
int main(){
	int n,m,z;
	while(true){
	cin>>n>>m;
	if(n==0&&m==0)break;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cin>>z>>tim[i][1];
		tim[i][0]=tim[i][1]-z;
	}
	for(int u=0;u<m;u++){
		string ans="Unknown";
		int cnt=-1;
		cin>>z;
		for(int i=0;i<n;i++)if(tim[i][0]<z&&tim[i][1]>=z){ans=a[i],cnt=z-tim[i][0];}
		cout<<ans;
		if(cnt>0)cout<<" "<<cnt;
		cout<<endl;
	}
	}
	return 0;
}

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

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,-1,1,-1,0};
const int dy[]={0,0,1,-1,1,-1,-1,1,0};

struct Era{
	string name;
	int by,wy;
};

Era era[1010];

int main() {
	int n,m;
	IL{
		cin>>n>>m;
		if(n==0&&m==0)break;
		rep(i,n){
			cin>>era[i].name>>era[i].by>>era[i].wy;
		}
		rep(i,m){
			int year=in();
			int j;
			rep0(j,n){
				if(era[j].wy-era[j].by<year&&year<=era[j].wy){
					cout<<era[j].name<<" "<<year-era[j].wy+era[j].by<<endl;
					break;
				}
			}
			if(j==n)cout<<"Unknown"<<endl;
		}
	}
	return 0;
}