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>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 200010;

int main(){
    int n, q;
    while(scanf("%d%d", &n, &q) && n){
        string s[n];
        int e[n], w[n];
        rep(i, n) cin >> s[i] >> e[i] >> w[i];
        int idx[n];
        rep(i, n) idx[i] = i;
        sort(idx, idx+n, [&](const int &a, const int &b){return w[a] < w[b];});
        while(q--){
            int x;
            scanf("%d", &x);
            auto it = lower_bound(idx, idx+n, x, [&](const int &a, int x){return w[a] < x;});
            if(it == idx+n) puts("Unknown");
            else{
                int i = *it;
                if(w[i]-x < e[i]) cout << s[i] << " " << e[i] - (w[i]-x) << "\n";
                else puts("Unknown");
            }
        }
    }
}

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

int32_t main() {
  while (true) {
    uint32_t N, Q;
    cin >> N >> Q;
    if (N == 0 && Q == 0) break;

    vector<tuple<uint32_t, uint32_t, string>> years;
    for (uint32_t _ = 0; _ < N; _++) {
      string name;
      uint32_t base_year, western_year;
      cin >> name >> base_year >> western_year;
      years.push_back(make_tuple(western_year, base_year, name));
    }

    for (uint32_t _ = 0; _ < Q; _++) {
      uint32_t year;
      cin >> year;
      bool found = false;
      for (auto iter = years.begin(); iter < years.end(); iter++) {
        uint32_t western_year = get<0>(*iter);
        uint32_t base_year = get<1>(*iter);
        uint32_t start_year = western_year + 1 - base_year;
        if (start_year <= year && year <= western_year) {
          found = true;
          cout << get<2>(*iter) << " " << western_year - start_year + 1 << endl;
          break;
        }
      }
      if (!found) {
        cout << "Unknown" << endl;
      }
    }
  }

  return 0;
}

C++: #include <iostream>

using namespace std;

const int MAX_N = 1000 + 5;
int era_y[MAX_N], wes_y[MAX_N];
string name[MAX_N];

int main()
{
    int N, Q;

    while (cin >> N >> Q, N || Q) {
        for (int i = 0; i < N; i++) 
            cin >> name[i] >> era_y[i] >> wes_y[i];

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

            cin >> q;
            bool flag = false;
            for (int j = 0; j < N; j++) {
                if (wes_y[j] - era_y[j] + 1 <= q && q <= wes_y[j]) {
                    flag = true;
                    cout << name[j] << " " << q - (wes_y[j] - era_y[j]) << endl;
                    break;
                }
            }

            if (!flag) {
                cout << "Unknown" << endl;
            }
        }
    }

    return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;



bool solve(){
	int n, q;
	cin>> n>> q;
	if(n==0 && q==0) return false;
	
	map<int, pair<string, int> > m;
	for(int i=0;i<n;i++){
		int by, wy;
		string str;
		cin>> str>> by>> wy;
		for(int j=0;j<by;j++){
			m[wy-j] = make_pair(str, by-j);
		}
	}
	
	for(int i=0;i<q;i++){
		int in;
		cin>> in;
		if(m.count(in)){
			cout<< m[in].first<< " "<< m[in].second<< endl;
		}else{
			cout<< "Unknown"<< endl;
		}
	}
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  int64 N, Q;
  while (cin >> N >> Q && N+Q) {
    vector<string> era(N);
    vector<int64> ey(N), wy(N);
    REP(i, N) {
      cin >> era[i] >> ey[i] >> wy[i];
    }
    REP(i, Q) {
      int64 y;
      cin >> y;
      bool ok = 0;
      REP(j, N) {
        if (wy[j] < y) continue;
        if (wy[j] - ey[j] < y) {
          cout << era[j] << " " << ey[j] - abs(y-wy[j]) << endl;
          ok = 1;
          break;
        }
      }
      if (!ok) {
        cout << "Unknown" << endl;
      }
    }
  }
}