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 <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

int N, Q;

void query(vector<pair<pair<int, int>, string>> &eras){
    int west_year; cin >> west_year;
    for(auto era: eras){
        if(era.first.first <= west_year && west_year <= era.first.second){
            cout << era.second << " " << west_year - era.first.first + 1 << endl;
            return;
        }
    }
    cout << "Unknown" << endl;
}

void solve(){
    vector<pair<pair<int, int>, string>> eras;
    
    for(int i=0; i<N; i++){
        string name;
        int base, year;
        cin >> name >> base >> year;
        eras.push_back(make_pair(make_pair(year-base+1, year), name));
    }
    
    while(Q--){
        query(eras);
    }
}


//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while(cin>>N>>Q, N|Q){
        solve();
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
#include<string>
using namespace std;
typedef struct{
  string str;
  int start,end;
}P;
int main(){
  int n,m,a;
  while(1){
    cin >> n >> m;
    if(n==0&&m==0)break;
    P data[n];
    for(int i=0;i<n;i++){
      cin >> data[i].str >> a >> data[i].end;
      data[i].start = data[i].end - a + 1;
    }
    for(int i=0;i<m;i++){
      cin >> a;
      bool ok=false;
      for(int j=0;j<n;j++){
	if(data[j].start<=a&&data[j].end>=a){
	  ok = true;
	  cout << data[j].str << " " << a-data[j].start+1 << endl;
	}
      }
      if(!ok)cout << "Unknown" << endl;
    }
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

struct era{
	string name;
	int from,to;
};

main(){
	vector<era> m;
	int n,q;
	while(cin>>n>>q){
		if(n==0 && q==0)break;
		
		m.clear();
		for(int i=0;i<n;i++){
			string name;
			int from,to;
			cin>>name>>from>>to;
			from=to-from+1;
			era tera=(era){name,from,to};
			//cout<<tera.name<<" "<<tera.from<<" "<<tera.to<<endl;
			m.push_back(tera);
		}
		
		for(int i=0;i<q;i++){
			int que;
			cin>>que;
			int flag=0;
			for(int j=0;j<n;j++){
				if(m[j].from<=que && m[j].to>=que){
					cout<<m[j].name<<" "<<-m[j].from+1+que<<endl;
					flag=1;
					break;
				}
			}
			if(flag==0)puts("Unknown");
		}
	}
}

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N,Q;
typedef pair<int,pair<int,string> > P;
vector<P> que;
int main(){
	while(cin>>N>>Q,N||Q){
		que.clear();
		int A[10010]={0};

		for(int i = 0;i < N;i++){
			string str;
			int eray,wesy;
			cin>>str>>eray>>wesy;
			que.push_back(P(wesy,mp(eray,str)));
			A[i] = wesy;
		}
		sort(que.begin(),que.end());
		sort(A,A+N);
		for(int i = 0;i<Q;i++){
			int wes;
			cin>>wes;
			int k = lower_bound(A,A+N,wes)-A;
			//cout<<que[k].first-wes<<endl;
			if(que[k].second.first>que[k].first-wes){
				cout <<que[k].second.second<<" "<<que[k].second.first-(que[k].first-wes)<<endl;
			}else{
				cout <<"Unknown"<<endl;
			}
		}
		/*(!que.empty()){
			cout <<que.top().first<<endl;
			que.pop();
		}*/
	}
	return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main() {
    int N, Q;
    while (cin >> N >> Q, N) {
        vector<string> era(N);
        vector<int> s(N), t(N);
        for (int i = 0; i < N; i++) {
            int eby;
            cin >> era[i] >> eby >> t[i];
            s[i] = t[i] - eby + 1;
        }
        for (int i = 0; i < Q; i++) {
            int x; cin >> x;
            bool unknown = true;
            for (int j = 0; j < N; j++) {
                if (s[j] <= x && x <= t[j]) {
                    cout << era[j] << " " << x - s[j] + 1 << endl;
                    unknown = false;
                    break;
                }
            }
            if (unknown) cout << "Unknown" << endl;
        }
    }
    return 0;
}