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 <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
  
using namespace std;

int main()
{
	int n, q;
	while(1){
		cin >> n >> q;
		if(n == 0 && q == 0) break;
		map<string, pair<int, int> > era;
		string inputs[1000];
		int by, wy;
		for(int i = 0; i < n; i++){
			cin >> inputs[i] >> by >> wy;
			era[inputs[i]] = make_pair<int, int>(wy - (by - 1), wy);
		}
		int query;
		for(int i = 0; i < q; i++){
			cin >> query;
			for(int j = 0; j < n; j++){
				if(era[inputs[i]].first <= query && era[inputs[i]].second >= query){
					cout << inputs[i] << " " << query - era[inputs[i]].first + 1 << endl;
					break;
				} else if(j == n - 1){
					cout << "Unknown" << endl;
				}
			}
		}
	}
	return 0;
}

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

int main(){
    int n;
    int q;
    while(cin>>n>>q,n){
        vector<tuple<int,int,string>> eras(n);
        for(int i=0;i<n;i++){
            string eraname;
            int eray;
            int wesy;
            cin>>eraname>>eray>>wesy;
            int startwes=wesy-eray+1;
            int endwes=wesy;
            eras[i]=make_tuple(startwes,endwes,eraname);
        }
        sort(eras.begin(),eras.end());
        for(int i=0;i<q;i++){
            int year;
            cin>>year;
            for(int j=0;j<=n;j++){
                if(j==n){
                    cout<<"Unknown"<<endl;
                    break;
                }
                if(get<0>(eras[i])<= year && year<=get<1>(eras[i])){
                    cout<<get<2>(eras[i])<<" "<<year-get<0>(eras[i])+1<<endl;
                    break;
                }


            }



        }
    }

    return 0;
}

C++: //36
#include<iostream>
#include<string>

using namespace std;

int main(){
  for(int n,q;cin>>n>>q,n|q;){
    string en[1000];
    int ey[1000],wy[1000];
    for(int i=0;i<n;i++){
      cin>>en[i]>>ey[i]>>wy[i];
    }
    while(q--){
      string s;
      int y=-1;
      int q;
      cin>>q;
      for(int i=0;i<n;i++){
	if(q<=wy[i]&&wy[i]-ey[i]+1<=q){
	  s=en[i];
	  y=ey[i]-(wy[i]-q);
	}
      }
      if(y==-1){
	cout<<"Unknown"<<endl;
      }else{
	cout<<s<<' '<<y<<endl;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

class C{
  public:
    int s, t;
    string name;
    C(){}
    C(int _s, int _t, string _n){ s = _s; t = _t; name = _n; }
};

int check(int y, vector<C> &v){
  REP(i, v.size()) if(v[i].s <= y && y <= v[i].t) return i;
  return -1;
}

int main() {
  int N, Q;
  while(cin >>N >>Q && N){
    vector<C> v(N);
    REP(i, N){
      cin >>v[i].name >>v[i].s >>v[i].t;
      v[i].s = v[i].t - v[i].s + 1;
    }
    REP(i, Q){
      int y; cin >>y;
      int r = check(y, v);
      if(r == -1) cout <<"Unknown" <<endl;
      else cout <<v[r].name <<" " <<y - v[r].s + 1 <<endl;
    }
  }
  return 0;
}

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

int main(){
    int n, q, x;
    while(cin >> n >> q, n+q){
        string name[n];
        int by[n], wy[n];
        for(int i = 0; i < n; i++)  cin >> name[i] >> by[i] >> wy[i];
        for(int i = 0; i < q; i++){
            cin >> x;
            int j;
            for(j = 0; j < n; j++){
                if(wy[j] >= x && x >= wy[j]-by[j]+1)    break;
            }

            if(j == n){
                cout << "Unknown" << endl;
            }else{
                cout << name[j] << " " << x - (wy[j]-by[j]) << endl;
            }
        }
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

typedef struct{
    string n;
    int a, b;
}data;

int main(){
    int n, q;
    while(cin >> n >> q, n||q){
        data d[1001];
        rep(i,n){
            string s;
            int a, b;
            cin >> s >> a >> b;
            d[i].n = s;
            d[i].a = b - a + 1;
            d[i].b = b;
        }
        rep(i,q){
            int a;
            bool f = true;
            cin >> a;
            rep(j,n){
                if(a >= d[j].a && a <= d[j].b){
                    cout << d[j].n << ' ' << a - d[j].a + 1 << endl;
                    f = false;
                    break;
                }
            }
            if(f) cout << "Unknown" << endl;
        }
    }
}