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 <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#define X first
#define Y second
#define sqr(x) (x)*(x)
using namespace std;
const double PI = acos(-1.0);
map<int,int>::iterator it;
typedef long long LL ;
#pragma comment(linker,"/STACK:102400000,102400000")

const int N = 1005;
struct CaoDai
{
    char nam[22];
    LL from,to;
}C[N];
int n,m;
int main()
{
    while(1)
    {
        scanf("%d%d",&n,&m);
        if(n==0&&m==0)break;
        for(int i=0;i<n;++i)
        {
            LL last,to;
            scanf("%s%lld%lld",C[i].nam,&last,&C[i].to);
            C[i].from=C[i].to-last+1;
        }
        LL y;
        for(int i=0;i<m;++i)
        {
            scanf("%lld",&y);
            int pos=-1;
            for(int j=0;j<n;++j)
            {
                if(y>=C[j].from&&y<=C[j].to)
                {
                    pos=j;
                    break;
                }
            }
            if(~pos)
            {
                printf("%s %lld\n",C[pos].nam,y-C[pos].from+1);
            }
            else
            {
                puts("Unknown");
            }
        }
    }
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const LL MOD = 1000000007;

template<typename T>
void dump(T a, int n) { for (int i = 0; i < n; i++) cout << a[i] << (i == n - 1 ? '\n' : ' '); }

template<typename T>
void dump(T a) { dump<T>(a, a.size()); }

// base_year, range, name
typedef tuple<int, int, string> Era;

int main(void) {
	for (int N, Q; cin >> N >> Q, N;) {
		vector<Era> eras;
		for (int i = 0; i < N; i++) {
			int year, range;
			string name;
			cin >> name >> range >> year;
			eras.emplace_back(year - range, range, name);
		}

		sort(eras.begin(), eras.end());

		for (int i = 0; i < Q; i++) {
			int qry;
			cin >> qry;

			auto it = upper_bound(eras.begin(), eras.end(), make_tuple(qry, 0, ""));

			if (it == eras.begin()) {
				cout << "Unknown" << endl;
				continue;
			}

			auto era = *(it - 1);
			
			int diff = qry - get<0>(era);
			if (diff <= get<1>(era)) {
				cout << get<2>(era) << " " << diff << endl;
			}else {
				cout << "Unknown" << endl;
			}
		}
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
string S[9999],U;int n,a,b,c,d,p[9999][2],i,j;
int main(){
while(1){
cin>>a>>b;if(!a){break;}
for(i=0;i<a;i++){
n=0;cin>>U>>c>>d;
S[i]=U;
p[i][0]=d-c+1;
p[i][1]=d;
}
for(i=0;i<b;i++){
cin>>c;
for(j=0;j<a;j++){
if(c>=p[j][0] && c<=p[j][1]){
printf("%s %d\n",S[j],c-p[j][0]+1);
goto E;
}
}
printf("Unknown\n");
E:;
}
}
}

C++: #include<iostream>
#include<string>
using namespace std;
string a[1000];
int time[1000][2];
int main(){
	int n,m,z;
	while(true){
	cin>>n>>m;
	if(n==0&&m==0)break;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cin>>z>>time[i][1];
		time[i][0]=time[i][1]-z;
	}
	for(int u=0;u<m;u++){
		string ans="Unknown";
		int cnt=-1;
		cin>>z;
		for(int i=0;i<n;i++)if(time[i][0]<z&&time[i][1]>=z){ans=a[i],cnt=z-time[i][0];}
		cout<<ans;
		if(cnt>0)cout<<" "<<cnt;
		cout<<endl;
	}
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, M;
	while ( cin >> N >> M, N || M ) {
		set<P> s;
		vector<string> name(N);
		vector<int> B(N);
		REP(i,N) {
			int b, y; cin >> name[i] >> b >> y;
			s.insert( P(y-b+1, i) );
			B[i] = b;
		}
		REP(i,M) {
			int y; cin >> y;
			auto it = s.upper_bound( P(y, inf) );
			if ( it == s.begin() ) {
				cout << "Unknown" << endl;
			}
			else {
				--it;
				int id = it->second;
				y = y-it->first+1;
				if (y <= B[id]) {
					cout << name[id] << " " << y << endl;
				}
				else {
					cout << "Unknown" << endl;
				}
			}
		}
	}
}

C++: #include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  int n,q,eby,wy,query;
  string en;
  while(cin>>n>>q,(n|q)!=0){
    map<int,string> era;
    REP(i,n){
      cin>>en>>eby>>wy;
      era[wy-eby]=en;
    }
    REP(i,q){
      cin>>query;
      auto iter=era.lower_bound(query);
      if(iter==era.begin())cout<<"Unknown"<<endl;
      else{
	iter--;
	cout<<(*iter).second<<" "<<query-(*iter).first<<endl;
      }
    }
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

string s[1010];
int start[1010],l[1010];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n,m; cin >> n >> m;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin >> s[i] >> l[i] >> start[i];
			start[i]-=l[i]-1;
		}
		while(m--){
			int t; cin >> t;
			bool f=0;
			for(int i=0;i<n;i++){
				if(start[i]<=t&&t<start[i]+l[i]){
					cout << s[i] << " " << (t-start[i]+1) << endl;
					f=1;
					break;
				}
			}
			if(!f)cout << "Unknown" << endl;
		}
	}
}