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 <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {

  while( true ) {

    long long int n, q;
    cin >> n >> q;
    if ( n == 0 ) break;

    vector< pair< string, pair< long long int, long long int > > > v;

    for ( long long int i = 0; i < n; i++ ) {

      string s;
      long long int e, w;
      cin >> s >> e >> w;
      v.push_back( make_pair( s, make_pair( e, w ) ) );

    }

    for ( long long int i = 0; i < q; i++ ) {

      long long int in;
      cin >> in;

      bool f = true;
      for ( long long int j = 0; j < n; j++ ) {
	if ( in > v[j].second.second - v[j].second.first && in <= v[j].second.second ) {
	  cout << v[j].first << " " << v[j].second.first - ( v[j].second.second - in ) << endl;
	  f = false;
	  break;
	}
      }
      if ( f == true ) {
	cout << "Unknown" << endl;
      }

    }

  }

  return 0;

}

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

using namespace std;

typedef long long ll;

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

  while(true){
      ll n,q;cin>>n>>q;
      if(n==0&&q==0) break;
      std::vector<string> ename;
      std::vector<ll> eyear,wyear;
      for(int i=0;i<n;i++){
          string s;ll a,b;
          cin>>s>>a>>b;
          ename.push_back(s);
          eyear.push_back(a);
          wyear.push_back(b);
      }
      for(int i=0;i<q;i++){
          ll y;cin>>y;
          bool flag=false;
          for(int j=0;j<n;j++){
              int st=wyear[j]-eyear[j]+1;
              if(st<=y&&y<=wyear[j]){
                  cout<<ename[j]<<" "<<y-st+1<<endl;
                  flag=true;
                  break;
              }
          }
          if(!flag) cout<<"Unknown"<<endl;
      }
  }
  return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
	int  n, q;
	while (cin >> n >> q, n | q){
		vector<pair<int, pair<int, string>>> data(n);
		REP(i, n){
			cin >> data[i].second.second;
			int len;
			cin >> len;
			cin >> data[i].second.first;
			data[i].first = data[i].second.first - len + 1;
		}
		SORT(data);
		REP(i, q){
			int year;
			cin >> year;
			REP(i, n){
				if (data[i].first <= year&&year <= data[i].second.first){
					cout << data[i].second.second <<" "<< year - data[i].first + 1 << endl;
					goto end;
				}
				if (data[i].first > year){
					cout << "Unknown" << endl;
					goto end;
				}
			}
			cout << "Unknown" << endl;
		end:
			continue;
		}

	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct data{
  string str;
  int era,western;
  bool operator<(const data& right)const{
    return western<right.western;
  }
};
int main(){
  int n,q,qyear,cal,i,j;
  while(1){
    cin >> n >> q;
    if(n==0&&q==0) break;
    vector<data> V(n);
    for(i=0;i<n;i++) cin >> V[i].str >> V[i].era >> V[i].western;
    sort(V.begin(),V.end());
    for(i=0;i<q;i++){
      cin >> qyear;
      for(j=0;j<n;j++){
	if(j==0){
	  if(qyear<=V[j].western){
	    cal=V[j].era-V[j].western+qyear;
	    if(cal>0){
	      cout << V[j].str << ' ' << cal << endl;
	    }else cout << "Unknown" << endl;
	    break;
	  }
	}else{
	  if(V[j-1].western<qyear&&qyear<=V[j].western){
	    cal=V[j].era-V[j].western+qyear;
	    if(cal>0){
	      cout << V[j].str << ' ' << cal << endl;
	    }else cout << "Unknown" << endl;
	    break;
	  }
	}
      }
    }
  }
  return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;



struct st{
	string name;
	int be;
	int en;
	st(){}
	st(string str, int y, int n){
		name = str;
		be = y - n + 1;
		en = y;
	}
};


bool inRange(int a, int b, int c){
	return a<=b && b<=c;
}

bool solve(){
	int n, q;
	cin>> n>> q;
	if(n==0 && q==0) return false;
	
	vector<st> vst;
	for(int i=0;i<n;i++){
		int by, wy;
		string str;
		cin>> str>> by>> wy;
		st tmp(str, wy, by);
		vst.pb(tmp);
	}
	
	for(int i=0;i<q;i++){
		int in;
		cin>> in;
		bool flg = false;
		for(int j=0;j<vst.size();j++){
			if(inRange(vst[j].be, in, vst[j].en)){
				cout<< vst[j].name<< " "<< in - vst[j].be + 1<< endl;
				flg = true;
				break;
			}
		}
		if(!flg) cout<< "Unknown"<< endl;
	}
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}