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){
    string s;
    ll a,b;
    vector<ll> x(n);
    vector<pair<ll,string>> v(n);
    rep(i,n){
      cin >> s >> a >> b;
      v[i] = mp(a,s);
      x[i] = b;
    }
    ll k;
    rep(i,q){
      cin >> k;
      auto it =lower_bound(all(x),k);
      auto dis = distance(x.begin(),it);
      if(v[dis].fi + k - *it > 0){
        cout << v[dis].se + " " <<v[dis].fi + ( k - *it) << endl;
      }
      else{
        cout << "Unknown" << endl;
      }
    }
  }
  return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <string>
#define MAX_N 1000
using namespace std;

string eraname[MAX_N];
int erabased[MAX_N], western[MAX_N];
int erafirst[MAX_N];

void search(int y, int n) {
  if (y < erafirst[0]) {
    cout << "Unknown" << endl;
    return;
  }
  for (int i = 1; i < n; i++) {
    if (y < erafirst[i]) {
      int temp = y - erafirst[i - 1] + 1;
      if (temp > erabased[i - 1]) {
	cout << "Unknown" << endl;
	return;
      } else {
	cout << eraname[i - 1] << ' ' << temp << endl;
	return;
      }
    }
  }
  cout << "Unknown" << endl;
  return;
}

void era_sort(int n) {
  for (int i = 0; i < n; i++) {
    for (int j = i; j > 0; j--) {
      if (erafirst[j - 1] > erafirst[j]) {
	swap(eraname[j - 1], eraname[j]);
	swap(erabased[j - 1], erabased[j]);
	swap(erafirst[j - 1], erafirst[j]);
	swap(western[j - 1], western[j]);
      }
    }
  }
}

void init() {
  for (int i = 0; i < MAX_N; i++) {
    eraname[i] = erabased[i] = western[i] = erafirst[i] = 0;
  }
}

int main() {
  while (true) {
    int n, q;
    cin >> n >> q;
    if (n == 0 && q == 0) return 0;

    init();

    for (int i = 0; i < n; i++) {
      cin >> eraname[i] >> erabased[i] >> western[i];
    }

    for (int i = 0; i < n; i++) {
      erafirst[i] = western[i] - erabased[i] + 1;
    }

    era_sort(n);

    for (int i = 0; i < q; i++) {
      int query;
      cin >> query;

      search(query, n);
    }
  }
}

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

using namespace std;

bool pairCompare(const std::pair<int, std::pair<int, string> >& firstElem, const std::pair<int, std::pair<int, string> >& secondElem) {
  return firstElem.first-firstElem.second.first < secondElem.first-secondElem.second.first;
}

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        vector<pair<int, pair<int, string> > >era;
        for(int i=0; i< n; i++){
           string name; int e, w;
           cin >> name >> e >> w;
           era.push_back(make_pair(w, make_pair(e, name)));
        }
        sort(era.begin(), era.end(), pairCompare);
        for(int i=0; i < m; i++){
            int y;
            cin >> y;
            bool is_find = false;
            for(int j=0; j < era.size(); j++){
                if(era[j].first-era[j].second.first+1 <= y  && y <= era[j].first){
                    cout << era[j].second.second << " " << y-(era[j].first-era[j].second.first) << endl;
                    is_find = true;
                    break;
                }
            }
            if(!is_find) cout << "Unknown" << endl;
        }
    }
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

typedef pair<int, pair<string, int> > P;

#define INF 1000000000

int main(){
    int n,q;
    while(cin>>n>>q, n|q){
        vector<P> vec;
        rep(i,n){
            string a; int y1,y2;
            cin>>a>>y1>>y2;
            vec.pb(mp(y2, mp(a, y1)));
            vec.pb(mp(y2-y1+1, mp(a,1)));
        }

        sort(all(vec));
        vec.erase(unique(all(vec)), vec.end());

        rep(i,q){
            int query;
            cin>>query;
            P que = mp(query, mp("",0));
            auto itr = lower_bound(all(vec), que);

            const string uk = "Unknown";
            if(itr==vec.end()){
                cout<<uk<<endl;
                continue;
            }
            if(itr->second.second==1){
                if(itr->first == query)
                    cout<<itr->second.first<<" 1"<<endl;
                else
                    cout<<uk<<endl;
            } else {
                itr--;
                int year = query - itr->first +1;
                cout<<itr->second.first<<" "<<year<<endl;
            }

        }

    }

    return 0;
}