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 <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int n, int m) {
    using type = pair<int, pair<int, string>>;
    vector<type> gen(n);
    for_each(ALL(gen), [](type &e) {
        string s;int a, b;
        cin >> s >> a >> b;
        e = MP(b, MP(a, s));
    });
    SORT(gen);
    VI ids(n);
    REP(i, n) ids[i] = gen[i].first;
    REP(i, m) {
        int num; cin >> num;
        int idx = distance(begin(ids), lower_bound(ALL(ids), num));
        //DEBUG(idx)
        if (!(0 <= idx && idx < n)) {
            cout << "Unknown" << endl;
            continue;
        }
        auto e = gen[idx];
        int buf = e.second.first - (e.first - num);
        if (buf > 0 && e.second.first >= buf) {
            cout << e.second.second << " " << buf << endl;
        } else {
            cout << "Unknown" << endl;
        }
    }
    return;
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n >> m, n) {
        solve(n, m);
        //return 0;
    }
}

C++: #include <string>
#include <iostream>
using namespace std;
int N, Q, v[1000], w[1000], x; string s[1000];
int main() {
	while (cin >> N >> Q, N | Q) {
		for (int i = 0; i < N; i++) cin >> s[i] >> v[i] >> w[i];
		for (int i = 0; i < Q; i++) {
			cin >> x; int f = 0;
			for (int j = 0; j < N; j++) {
				if (w[j] - v[j] < x && x <= w[j]) {
					cout << s[j] << ' ' << x - w[j] + v[j] << endl; f = 1; break;
				}
			}
			if (!f) cout << "Unknown" << endl;
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    while (1) {
        int n, q;
        cin >> n >> q;
        if (n == 0 && q == 0) return 0;
        
        vector<pair<int, string> > nengo;
        for (int i = 0; i < n; i++) {
            string s;
            int ny, wy;
            cin >> s >> ny >> wy;
            nengo.emplace_back(wy - (ny - 1), s);
            nengo.emplace_back(wy, "{");
        }
        sort(nengo.begin(), nengo.end());
        
        for (int i = 0; i < q; i++) {
            int qy, in = 0;
            cin >> qy;
            for (int j = 0; j < nengo.size(); j++) {
                if (nengo[j].first < qy) {
                    if (nengo[j].second == "{") in--;
                    else in++;
                }
                else if (nengo[j].first == qy && nengo[j].second != "{") in++;
                else {
                    if (in == 0) cout << "Unknown" << endl;
                    else cout << nengo[j - 1].second << " " << qy + 1 - nengo[j - 1].first << endl;
                    break;
                }
            }
        }
    }
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;

int N, Q;

int main() {

	while ( cin >> N >> Q && N ) {

		map<int,string> start;
		map<string,int> finish;
		string name;

		for ( int i = 0; i < N; i++ ) {

			int local, western;

			cin >> name >> local >> western;

			start[western - local + 1] = name;

			if ( finish[name] < western ) {

				finish[name] = western;

			}

		}

		for ( int i = 0; i < Q; i++ ) {

			int western;

			cin >> western;

			bool ok = false;

			for ( map<int,string>::iterator s = start.begin(); s != start.end(); s++ ) {

				if ( s->first <= western && finish[s->second] >= western ) {

					cout << s->second << " " << western - s->first + 1 << endl;
					ok = true;
					break;

				}

			}

			if ( ! ok ) {

				cout << "Unknown" << endl;

			}

		}

	}

}

C++: #include<iostream>
#include<tuple>
#include<string>
using namespace std;
#define MAX_V 1010
#define rep(i, n) for(int i = 1; i <= n; i++)

int main(){
	while(1){
		int N, Q, EraBasedYear, WesternYear, Query;
		string EraName;
		tuple<string, int, int> temp[MAX_V];
		
		cin>>N>>Q;
		
		if(!N&&!Q) break;
		
		rep(i, N){
			cin>>EraName>>EraBasedYear>>WesternYear;
			
			temp[i] = make_tuple(EraName,EraBasedYear,WesternYear);
		}
		
		rep(i,Q){
			cin>>Query;
			bool flag = false;
			rep(j,N){
				if(get<2>(temp[j]) -  get<1>(temp[j]) < Query && Query <= get<2>(temp[j])){
					cout<<get<0>(temp[j])<<" "<<Query + get<1>(temp[j]) - get<2>(temp[j])<<endl;
					flag = true;
					break;
				}
			}
			if(!flag)cout<<"Unknown"<<endl;
		}
		
	}
}