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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-20;
const long INF = 1e10;

int f(int n,int k){
	if(n==1)return 0;
	return (f(n-1,k)+k)%n;
}
int main(){
	int n,q;
	while(cin>>n>>q){
		if(n==0&&q==0)break;
		string str;long n1,n2;
		vector<pair<long,string> >pi;
		vector<long>bd;
		REP(i,n){
			cin>>str>>n1>>n2;
			pi.PB(MP(n2-n1+1,str));
			bd.PB(n2);
		}
		SORT(pi);SORT(bd);
		vector<long>num;vector<string>nm;
		REP(i,SZ(pi)){
			num.PB(pi[i].first);
			nm.PB(pi[i].second);
		}
		REP(i,q){
			long que;
			cin>>que;
			int cnt=upper_bound(ALL(num),que)-num.begin();
			if(cnt==0||que>bd[cnt-1]){
				cout<<"Unknown"<<endl;
			}else{
				cout<<nm[cnt-1]<<" "<<que-num[cnt-1]+1<<endl;
			}
		}
	}
	
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;
#define debug2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define debugg(g,h,w) rep(i,0,h) { rep(j,0,w) cout << g[i][j] << " "; cout << endl;}
#define debugv(v) for(auto&& x : v){cout << x << " ";} cout << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
typedef pair<ll, ll> Pll;

struct era{
	string name;
	int s;
	int e;
	era(){};
	era(string _n, int _s, int _e) {name = _n, s = _s, e = _e;};
	bool operator<(const era& rhs) {
		return e < rhs.e;
	}
};
struct b {
	bool operator ()(era const& ms, int i) {
		return ms.e < i;
	}
};
era a[1010];

int main()
{
	while (1) {
		int n, q;
		cin >> n >> q;
		if (!n && !q) break;
		memset(a, 0, sizeof(a));

		rep(i,0,n) {
			string name;
			int s, e;
			cin >> name >> s >> e;
			a[i] = {name,s,e};
		}
		sort(a, a+n);
		//rep(i,0,n) cout << a[i].name << endl;

		rep(i,0,q) {
			int x;
			cin >> x;
			auto *p = lower_bound(a, a+n, x, b());
			int check = a[p-a].e - x;
			if (check < a[p-a].s) cout << a[p-a].name << " " << a[p-a].s-check << endl;
			else cout << "Unknown" << endl;
		}

	}
	return 0;
}

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

int n, q;
string era[1000]; int offset[1000]; int year[1000];

int main() {
	while (cin >> n >> q) {
		if (!n) break;
		int i, j;
		
		for (i = 0; i < n; i++) cin >> era[i] >> offset[i] >> year[i];
		for (i = 0; i < q; i++) {
			int y;
			vector<int> ansId;
			
			cin >> y;
			for (j = 0; j < n; j++) {
				int firstYear = year[j] - offset[j] + 1;
				if (firstYear <= y && y <= year[j]) {
					ansId.push_back(j);
				}
			}
			if (ansId.size() != 1) { cout << "Unknown" << endl; }
			else { cout << era[ansId[0]] << " " << offset[ansId[0]] - year[ansId[0]] + y << endl; }
		}
	}
	return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, Q;
    for (int N, Q; cin >> N >> Q and N and Q;) {
        map<int, map<string, int>> dict;
        rep(i, N) {
            string e;
            int a, b;
            cin >> e >> a >> b;
            dict[b][e]=a;
        }
        for (auto &a : dict) {
            for (auto &b : a.second) {
                for (int i=b.second-1, cnt=1; i>=1; --i, ++cnt) {
                    dict[a.first-cnt][b.first] = i;
                }
            }
        }
        rep(i, Q) {
            int d;
            cin >> d;
            auto itr = dict.find(d);
            if (itr == dict.end()) {
                cout << "Unknown" << endl;
            }
            else {
                for (auto &tmp : itr->second) {
                    cout << tmp.first << ' ' << tmp.second << endl;
                    break;
                }
            }
        }
    }
    return 0;
}