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;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<string, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,q;
PPI ps[1111];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>q;
		if(n==0)break;
		rep(i,n){
			cin>>ps[i].fi.fi>>ps[i].fi.se>>ps[i].se;
		}
		rep(i,q){
			int a;
			cin>>a;
			bool ok=false;
			rep(i,n){
				if(ps[i].se-ps[i].fi.se<a&&a<=ps[i].se){
					ok=true;
					cout<<ps[i].fi.fi<<" "<<ps[i].fi.se-(ps[i].se-a)<<endl;
				}
			}
			if(!ok)cout<<"Unknown"<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#define N 1000
using namespace std;

int main(){
  while(1){
    int n,q,e[N],w[N],que,f;
    string str[N];
    cin>>n>>q;
    if(n+q==0) break;
    for(int i=0;i<n;i++)cin>>str[i]>>e[i]>>w[i];
    for(int i=0;i<q;i++){
      cin>>que,f=0;
      for(int j=0;j<n;j++)if(e[j]-(w[j]-que)>0 && e[j]-(w[j]-que)<=e[j]) cout<<str[j]<<" "<<e[j]-(w[j]-que)<<endl,f=1;
      if(!f) cout<<"Unknown"<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

string name[1000];
int num[1000];
int year[1000];
int n,q;

int main() {
  while(cin >> n >> q, n||q) {
    REP(i,n) {
      cin >> name[i] >> num[i] >> year[i];
    }
    REP(i,q) {
      int y;cin >> y;
      bool f = 0;
      REP(j,n) {
        if (year[i]-num[i]+1 <= y && y<=year[i]) {
          cout << name[i] << " " << y-year[i]+num[i] << endl;
          f = 1;
          break;
        }
      }
      if (!f) cout << "Unknown" << endl;
    }
  
  }
}

C++: #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int N, M;
    while (cin >> N >> M, N|M) {
        vector<pair<pii, string>> Q;
        REP(i, N) {
            string s;
            int era, western;
            cin >> s >> era >> western;
            Q.push_back({{western, era}, s});
            Q.push_back({{western-era+1, 1}, s});
        }
        SORT(Q);
        REP(i, M) {
            int q;
            cin >> q;
            if (q < Q[0].first.first || q > Q[SZ(Q)-1].first.first) {
                cout << "Unknown" << endl;
            } else {
                bool found = false;
                FOR(i, 1, SZ(Q)) {
                    if (Q[i-1].second == Q[i].second &&
                        Q[i-1].first.first <= q && q <= Q[i].first.first) {
                        int d = q - Q[i-1].first.first;
                        cout << Q[i-1].second << " " << Q[i-1].first.second + d << endl;
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    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;
};

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;
	}

	sort(info,info+N);

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

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


int main(){

	int N,Q;

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

		func(N,Q);
	}

	return 0;
}