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 rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, Q;
    for (int N, Q; cin >> N >> Q and N and Q;) {
        vector<pair<int,pair<string, int>>> p;
        rep(i, N) {
            string e;
            int a, b;
            cin >> e >> a >> b;
            p.push_back(make_pair(b, make_pair(e, a)));
        }
        sort(p.begin(), p.end(),[](const pair<int, pair<string, int>>& a, const pair<int, pair<string, int>>& b) {
            return a.first < b.first;
        });
        rep(i, Q) {
            int d;
            cin >> d;
            auto itr = *lower_bound(p.begin(), p.end(), make_pair(d, make_pair("", 0)), [](const pair<int, pair<string, int>>& a, const pair<int, pair<string, int>>& b) {
                return a.first < b.first;
            });

            if (itr.first-itr.second.second+1 <= d and d <= itr.first) {
                cout << itr.second.first << ' ' << itr.second.second - (itr.first - d) << endl;
            }
            else {
                cout << "Unknown" << endl;
            }
        }
    }
    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;
#define debug2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define debugg(g,h,w) rep(i,0,h) { rep(j,0,w) cout << g[i][j] << " "; cout << endl;}
#define debugv(v) for(auto&& x : v){cout << x << " ";} cout << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
typedef pair<ll, ll> Pll;

struct era{
	string name;
	int s;
	int e;
	era(){};
	era(string _n, int _s, int _e) {name = _n, s = _s, e = _e;};
	bool operator<(const era& rhs) {
		return e < rhs.e;
	}
};
struct b {
	bool operator ()(era const& ms, int i) {
		return ms.e < i;
	}
};
era a[1010];

int main()
{
	while (1) {
		int n, q;
		cin >> n >> q;
		if (!n && !q) break;
		memset(a, 0, sizeof(a));

		rep(i,0,n) {
			string name;
			int s, e;
			cin >> name >> s >> e;
			a[i] = {name,s,e};
		}
		sort(a, a+n);
		//rep(i,0,n) cout << a[i].name << endl;

		rep(i,0,q) {
			int x;
			cin >> x;
			auto *p = lower_bound(a, a+n, x, b());
			int check = a[p-a].e - x;
			if (p-a < n && check < a[p-a].s) cout << a[p-a].name << " " << a[p-a].s-check << endl;
			else cout << "Unknown" << endl;
		}

	}
	return 0;
}

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

typedef struct{
  string name;
  long long start;
  long long end;
}Era;

int main()
{
  Era E[1000];
  int N,Q,s;

  while(1){
    cin>>N>>Q;
    if(N==0&&Q==0)break;
    for(int i=0;i<N;i++){
      cin>>E[i].name>>s>>E[i].end;
      E[i].start=(E[i].end-s);
    }
    for(int i=0;i<Q;i++){
      cin>>s;
      for(int j=0;j<N;j++){
	if(E[j].start<s && s<=E[j].end){
	  cout<<E[j].name<<" "<<(s-E[j].start)<<endl;
	  break;
	}
        if(j==N-1)cout<<"Unknown"<<endl;
      }
    }
  }
  return 0;
}

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

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

int n, q;

class node
{
public:
	string name;
	int start, end;

	node(string n, int a, int b):name(n), start(b-a+1), end(b){}

	bool is_in_range(int year)
	{
		return start <= year && year <= end;
	}
};

int main(void)
{
	while(cin >> n >> q, n|q) {
		vector<node> vs;
		rep(i, n) {
			string name;
			int erabased, westernyear;
			cin >> name >> erabased >> westernyear;
			vs.push_back(node(name, erabased, westernyear));
		}

		rep(i, q) {
			int year;
			cin >> year;
			bool f = false;
			rep(j, vs.size()) {
				if(vs[j].is_in_range(year)) {
					printf("%s %d\n", vs[j].name.c_str(), year-vs[j].start+1);
					f = true;
					break;
				}
			}
			if (!f)
				printf("Unkown\n");
		}
	}
	return 0;
}