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++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

typedef tuple<int, int, string> era;

void solve() {
  int n, q;
  while (cin >> n >> q, n) {
    vector<era> v;
    while (n--) {
      string name;
      int baseY, westY;
      cin >> name >> baseY >> westY;
      v.emplace_back(westY - baseY + 1, westY, name);
    }
    while (q--) {
      int y;
      cin >> y;
      rep(i, v.size()) {
        string name;
        int s, e;
        tie(s, e, name) = v[i];
        if (s <= y && y <= e) {
          cout << name << ' ' << y - s + 1 << endl;
          goto next;
        }
      }
      cout << "Unknown" << endl;
    next:;
    }
  }
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;
struct aa {
	string st;
	int from;
	int to;
};
bool operator>(const aa&l, const aa&r) {
	return l.from> r.from;
}
bool operator==(const aa&l, const aa&r) {
	return l.from== r.from;
}
class Compare {
public:
	//aaが昇順に並ぶ
	bool operator()(const aa&l, const aa&r) {
		return l.from> r.from;
	}
};
bool comp_func(const aa&l, const aa&r) {
	return l.from < r.from;
}
int main() {
	while (1) {
		int N, Q; cin >> N >> Q;
		if (!N)break;
		vector<aa>names;
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			int eby, year; cin >> eby >> year;
			names.push_back(aa{ st,year - eby + 1,year });

		}
		sort(names.begin(), names.end(), [](const aa&l, const aa&r) {return l.from < r.from; });
		for (int i = 0; i < Q; ++i) {
			int y; cin >> y;

			aa aaa{ "",y,y };
			auto it = upper_bound(names.begin(), names.end(), aaa, comp_func);
			if (it == names.begin())cout << "Unknown" << endl;
			else {
				if (prev(it)->to >= y) {
					cout << prev(it)->st << " " << y - prev(it)->from + 1 << endl;
				}
				else {
					cout << "Unknown" << endl;
				}
			}
		}
	}

	return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
#include<functional>
using namespace std;
int main(){
	int n,q;
	while(cin>>n>>q,n|q){
		map<int,pair<bool,string>,greater<int> > mp;
		for(int i=0;i<n;i++){
			string s;
			int a,b;
			cin>>s>>a>>b;
			mp.insert(make_pair(b+1,make_pair(false,s)));			
			mp.insert(make_pair(b-a+1,make_pair(true,s)));
		}
		for(int i=0;i<q;i++){
			int a;
			cin>>a;
			map<int,pair<bool,string>,greater<int> >::iterator it=mp.lower_bound(a);
			if(it==mp.end() || !it->second.first){
				cout<<"Unknown"<<endl;
			}else{
				cout<<it->second.second<<' '<<a-it->first+1<<endl;
			}
		}
	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
#include<functional>
using namespace std;
int main(){
	int n,q;
	while(cin>>n>>q,n|q){
		map<int,pair<bool,string>,greater<int> > mp;
		for(int i=0;i<n;i++){
			string s;
			int a,b;
			cin>>s>>a>>b;
			if(mp.find(b+1)==mp.end())mp.insert(make_pair(b+1,make_pair(false,s)));			
			mp.insert(make_pair(b-a+1,make_pair(true,s)));
		}
		for(int i=0;i<q;i++){
			int a;
			cin>>a;
			map<int,pair<bool,string>,greater<int> >::iterator it=mp.lower_bound(a);
			if(it==mp.end() || !it->second.first){
				cout<<"Unknown"<<endl;
			}else{
				cout<<it->second.second<<' '<<a-it->first+1<<endl;
			}
		}
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

void hoge(int N, int Q){

   string a[N];
   int b[N], c[N], d[2*N];
   for(int i=0; i<N; i++){
      cin>> a[i]>> b[i]>> c[i];
      d[2*i]=c[i]-b[i]+1;
      d[2*i+1]=c[i];
   }

   for(int q=0; q<Q; q++){
      int e;
      cin>> e;
      for(int i=0; i+1<N; i+=2){
         if(d[i]<=e&&e<=d[i+1]){
            cout<< a[i/2]<< " "<< e-d[i]+1<< endl;
            goto ikd;
         }
      }
      cout<< "Unknown"<< endl;
      ikd:;
   }
}

int main(){

   while(1){
      int N, Q;
      cin>> N>> Q;
      if(!(N||Q)) break;

      hoge(N, Q);
   }

   return 0;
}

C++: #include <string>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int N, Q, A, B, R; pair<int, string> D[1000];
int main() {
	while (true) {
		scanf("%d%d", &N, &Q);
		if (N == 0 && Q == 0) break;
		for (int i = 0; i < N; i++) cin >> D[i].second >> A >> B, D[i].first = B - A;
		sort(D, D + N);
		for (int i = 0; i < Q; i++) {
			scanf("%d", &R);
			bool flag = false;
			for (int j = N - 1; j >= 0; j++) {
				if (D[i].first < R) {
					printf("%s %d\n", D[i].second.c_str(), R - D[i].first); flag = true; break;
				}
			}
			if (!flag) {
				printf("Unknown\n");
			}
		}
	}
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

const int SZ=1005;
int l[SZ],r[SZ];
string name[SZ];

signed main()
{   
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,q;
    while(cin>>n>>q,n)
    {
        REP(i,n){
            int a;
            cin>>name[i]>>a>>r[i];
            l[i]=r[i]-a;
        }
        while(q--){
            int year; cin>>year;
            REP(i,n){
                if(l[i]<year && year<=r[i]){
                    cout<<name[i]<<" "<<year-l[i]<<endl;
                    goto g;
                }
            }
            cout<<"Unknown"<<endl;
        g:;
        }
    }       
}