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 pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,q;
  while(cin >> n >> q && n+q){
    vector<string> s(n);
    vector<pll> v(n);
    map<ll,string> Q;
    rep(i,10000){
      Q[i] = "Unknown";
    }
    rep(i,n){
      cin >> s[i] >> v[i].fi >> v[i].se;
      rep(j,v[i].fi){
        Q[v[i].se - j] = s[i] + " " + to_string(v[i].fi - j);
      }
    }
    ll k;
    rep(i,q){
      cin >> k;
      cout << Q[k] << endl;
    }
  }
  return 0;
}

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

using namespace std;

typedef struct names {
	string en;
	int eby;
	int wy;
};

/*
void sort(names array[], int S) {
	int sorted, last;
	int i;
	names temp;

	sorted = S;
	while(sorted) {
		last = 0;
		for(i = 0; i < sorted - 1; i++) {
			if(array[i].wy > array[i + 1].wy) {
				temp = array[i];
				array[i] = array[i + 1];
				array[i + 1] = temp;
				last = i + 1;
			}
		}

		sorted = last;
	}
}
*/

bool comp(names A, names B) {
	return A.wy < B.wy;
}

int main(void) {
	int N, Q;
	names data[1024];
	int query;
	int next;

	while(cin >> N >> Q, N != 0 || Q != 0) {
		for(int i = 0; i < N; i++)
			cin >> data[i].en >> data[i].eby >> data[i].wy;
		sort(data, data + N, comp);
		
		for(int i = 0; i < Q; i++) {
			cin >> query;
			for(next = 0; query > data[next].wy && next < N; next++);
			if(next == N) {
				cout << "Unknown" << endl;
				continue;
			}

			if(data[next].eby + query - data[next].wy > 0)
				cout << data[next].en << " " << data[next].eby + query - data[next].wy << endl;
			else
				cout << "Unknown hoge" << endl;
		}
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n, q;
	while (scanf("%d%d", &n, &q), n) {
		map<int, string>mp;
		rep(i, n) {
			string s;
			int j, k;
			cin >> s >> j >> k;
			mp[k - j] = s;
		}
		rep(i, q) {
			int d; scanf("%d", &d);
			auto it = mp.lower_bound(d);
			if (it != mp.end() && (*it).first == d) {
				puts("Unknown");
				continue;
			}
			it--;
			if (it == --mp.begin()) {
				puts("Unknown");
				continue;
			}
			cout << (*it).second << ' ' << d - (*it).first << endl;
		}
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
struct japan{
    char s[100];
    int st,e;
}j[2000];


int main(){
    int n,m,h;
    while(scanf("%d%d",&n,&m)){
        if(n==0&&m==0) break;
        int a,b;
        for(int i=0;i<n;i++){
            scanf("%s%d%d",j[i].s,&a,&b);
            j[i].st=b-a+1;
            j[i].e=b;
        }
        for(int i=0;i<m;i++){
            scanf("%d",&h);
            int flag=0;
            for(int k=0;k<n;k++){
                if(h>=j[k].st && h<=j[k].e){
                    printf("%s %d\n",j[k].s,h-j[k].st+1);
                    flag=1;
                    break;
                }
            }
            if(flag==0){
                printf("Unknown\n");
            }
        }
    }
    return 0;
}
/*
4 3
taisho 6 1917
heisei 22 2010
meiji 10 1877
showa 62 1987
*/

C++: #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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<pair<string,pii> > v(n);
		rep(i,n){
			cin>>v[i].F>>v[i].S.F>>v[i].S.S;
		}
		rep(i,m){
			int t;
			cin>>t;
			bool f=true;
			rep(j,n){
				if(v[j].S.S>=t&&v[j].S.S-v[j].S.F+1<=t){
					cout<<v[j].F<<" "<<v[j].S.F-(v[j].S.S-t)<<endl;
					f=false;
					break;
				}
			}
			if(f) cout<<"Unknown\n";
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}