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 <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
	while(1){
		ll n,m; cin >> n >> m;
		if(n+m == 0) break;
		map<int,string> mp;
		map<string,int> mx;
		rep(i,n){
			string s; ll a,b; cin >> s >> a >> b;
			mp[b-a+1] = s;
			chmax(mx[s],a);
		}
		rep(i,m){
			ll a; cin >> a;
			auto itr = mp.upper_bound(a);
			if(itr == mp.begin()){
				cout << "Unknown" << endl;
				continue;
			}
			itr--;
			ll d = a - (*itr).first + 1;
			if(mx[(*itr).second] < d) cout << "Unknown" << endl;
			else print2((*itr).second, d);
		}
	}
}

C++: #include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#define P pair<int,int>
using namespace std;

int main() {
	int a, b;
	while (cin >> a >> b, a | b) {
		map<P,string>c;
		for (int d = 0; d < a; d++) {
			string e; int f, g;
			cin >> e >> f >> g;
			c[P(g - f + 1, g)] = e;
		}
		for (int d = 0; d < b; d++) {
			int e; cin >> e;
			for (auto f = --c.end(); f != --c.begin(); f--) {
				if (e >= (*f).first.first&&e<=(*f).first.second) {
					cout << (*f).second << " " << e - (*f).first.first + 1 << endl;
					goto l;
				}
			}
			puts("Unknown");
		l:;
		}
	}
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
  while(true){
    int N,Q;
    cin >> N >> Q;
    if(N==0&&Q==0)break;
    map<int,string> M;
    for(int i = 0; i < N; ++i){
      string era;
      int now;
      int y;
      cin >> era >> now >> y;
      M[y-now+1]=era;
      M[y]=era;
    }
    for(int i = 0; i < Q; ++i){
      int y;
      int res=-1;
      string res_era;
      cin >> y;
      map<int,string>::iterator itm = M.lower_bound(y);
      if(itm==M.end())itm=M.begin();
      if(itm!=M.begin()){
	--itm;
      }
      while(true){
	if(itm->first>y){
	  break;
	}else{
	  map<int,string>::iterator itm2 = itm;
	  itm2++;
	  if(itm2==M.end())break;
	  if( y >= itm->first && itm->second == itm2->second ){
	    res = y - itm->first + 1;
	    res_era = itm->second;
	  }
	}
	++itm;
      }
      if(res>0){
	cout << res_era << ' ' << res << endl;
      }else{
	cout << "Unknown" << endl;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

#define all(c) (c).begin(), (c).end()

int main(){
    int N, Q;
    while(cin >> N >> Q, N|Q){
        typedef tuple<int, int, string> Data;
        vector<Data> era;
        while(N--){
            string name;
            int eyear, wyear;
            cin >> name >> eyear >> wyear;
            era.emplace_back(wyear - eyear + 1, wyear, name);
        }
        sort(all(era));
        auto comp = [](Data& d, int x){return get<1>(d) < x;};
        while(Q--){
            int query, one = 0, known = 0;
            string name;
            cin >> query;
            if(query <= get<1>(era.back()))tie(one, known, name) = *lower_bound(all(era), query, comp);
            if(one <= query && query <= known)cout << name << " " << query - one + 1 << '\n';
            else cout << "Unknown\n";
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, q;
  while (cin >> n >> q, n || q)
  {
    vector<pair<pair<string, int>, int>> db(n);
    for (auto &e : db)
    {
      cin >> e.first.first >> e.first.second >> e.second;
    }
    sort(db.begin(), db.end(), [](pair<pair<string, int>, int> a, pair<pair<string, int>, int> b) { return a.second < b.second; });
    for (int i = 0; i < q; ++i)
    {
      int query;
      cin >> query;
      bool flag = true;
      for (int j = 0; j < n; ++j)
      {
        int year = db[j].first.second - (db[j].second - query);
        if (query <= db[j].second && year > 0)
        {
          cout << db[j].first.first << ' ' << year << endl;
          flag = false;
          break;
        }
      }
      if (flag)
        cout << "Unknown" << endl;
    }
  }

  return 0;
}