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 FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

struct era{ string name; int pass, now; };
vector<era> v;
bool comp(const era& e1, const era &e2)
{
	return e1.now < e2.now;
}

int main()
{
	int n, q;
	while (cin >> n >> q, n)
	{
		v.clear();
		REP(i, n)
		{
			int a, b;
			string s;
			cin >> s >> a >> b;
			v.push_back(era{ s, a, b });
		}
		v.push_back(era{ "", 0, INF });
		sort(ALL(v), comp);
		REP(i, q)
		{
			int m;
			cin >> m;
			int j = 0;
			for (; j < n; j++)
			{
				if (v[j].now >= m) break;
			}
			if (v[j].now - m < v[j].pass) cout << v[j].name << " " << v[j].pass - (v[j].now - m) << endl;
			else puts("Unknown");
		}
	}
	return 0;
}

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

int main(){

  for(int n,q;cin>>n>>q,n;){
    vector<pair<string, pair<int, int >>> era;

    for(int i=0;i<n;++i){
      string a;int b,c;
      cin>>a>>b>>c;
      era.push_back(make_pair(a,make_pair(c-b,c)));
    }

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

      for(int j=0;j<n;++j){
        if(era[j].second.first<query&&query<=era[j].second.second){
          cout << era[j].first << " " << query-era[j].second.first << endl;
          break;
        }

        if(j==q-1) cout << "Unknown" << endl;
      }
    }
  }

  return 0;
}