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 "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	while (N) {
		set<pair<int, pair<string, bool>>>s;
		for (int i = 0; i < N; i++) {
			string t;
			int a,b;
			cin >> t >> a >> b;
			s.insert({ b - a + 1,{t,true} });
			s.insert({ b,{t,false} });
		}
		vector<pair<int, pair<string, bool>>>v(s.begin(), s.end());
		v.push_back({ INT_MAX,{"olphe",true} });
		for (int i = 0; i < M; i++) {
			int a;
			cin >> a;
			for (int j = 0; j < v.size()/2; j++) {
				if (v[j*2].first > a) {
					cout << "Unknown\n";
					break;
				}
				if (v[j * 2].first <= a&&v[j * 2 + 1].first >= a) {
					cout << v[j * 2].second.first << " " << a - v[j * 2].first + 1 << endl;
					break;
				}
			}
		}
		cin >> N >> M;
	}
	return 0;
}

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;
}

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

int32_t main() {
  while (true) {
    uint32_t N, Q;
    cin >> N >> Q;
    if (N == 0 && Q == 0) break;

    vector<tuple<uint32_t, uint32_t, string>> years;
    for (uint32_t _ = 0; _ < N; _++) {
      string name;
      uint32_t base_year, western_year;
      cin >> name >> base_year >> western_year;
      years.push_back(make_tuple(western_year, base_year, name));
    }

    for (uint32_t _ = 0; _ < Q; _++) {
      uint32_t year;
      cin >> year;
      bool found = false;
      for (auto iter = years.begin(); iter < years.end(); iter++) {
        uint32_t western_year = get<0>(*iter);
        uint32_t base_year = get<1>(*iter);
        uint32_t start_year = western_year + 1 - base_year;
        if (start_year <= year && year <= western_year) {
          found = true;
          cout << get<2>(*iter) << " " << year - start_year + 1 << endl;
          break;
        }
      }
      if (!found) {
        cout << "Unknown" << endl;
      }
    }
  }

  return 0;
}

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

int main(){
  while(1){
    int n,q,e[1000],w[1000],que[1000],f;
  string str[1000];
  cin>>n>>q;
  if(n+q==0) break;
  for(int i=0;i<n;i++)cin>>str[i]>>e[i]>>w[i];
    for(int i=0;i<q;i++) cin>>que[i];

    for(int i=0;i<q;i++){
      f=0;
      for(int j=0;j<n;j++)if(e[j]-(w[j]-que[i])>0 && e[j]-(w[j]-que[i])<=e[j]) cout<<str[j]<<" "<<e[j]-(w[j]-que[i])<<endl,f=1;
      if(f==0) cout<<"Unknown"<<endl;
  }
  }
  return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<ll, ll> P;
int main()
{
  int N, Q;
  while(cin>>N>>Q,N||Q) {
    map<ll, string> era; // ?????????????????´, ?????£?????????
    map<ll, ll> year; // ?????????????????´, ?§???????????????´
    FOR(i,0,N) {
      string s;
      ll a, b;
      cin >> s >> a >> b;
      era[b] = s;
      year[b] = b - a + 1;
    }
    FOR(i,0,Q) {
      ll in; cin >> in;
      auto y = era.lower_bound(in);
      string e = y->second;
      ll st = year[y->first];
      if(st <= in && y->first >= in) {
        cout << e << " " << in - st + 1 << endl;
      } else {
        puts("Unknown");
      }
    }
  }
  return 0;
}

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


int main(){
    int N, Q;
    while(cin >> N >> Q, N+Q){
        vector<pair<int, int>> year;
        map<int, string> era;
        while(N--){
            string s;
            int b, y;
            cin >> s >> b >> y;
            year.emplace_back(y-b, 1);
            year.emplace_back(y, 0);
            era[y] = s;
        }
        sort(begin(year), end(year));
        while(Q--){
            int y;
            cin >> y;
            auto p = lower_bound(begin(year), end(year), make_pair(y, -1));
            if(p == end(year) or p->second == 1) cout << "Unknown" << endl;
            else cout << era[p->first] << ' ' << y-(p-1)->first << endl;
        }
    }
    return 0;
}