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

typedef pair<int,int> P;

int main() {
  for(int N, Q; cin >> N >> Q, N || Q; ) {
    map<string, P> database;
    for(int i = 0; i < N; i++) {
      string ename; int eyear, wyear;
      cin >> ename >> eyear >> wyear;
      if(database.count(ename)) {
        database[ename] = P(wyear - eyear + 1, max(database[ename].second, wyear));
      }
      else {
        database[ename] = P(wyear - eyear + 1, wyear);
      }
    }
    while(Q--) {
      int y; cin >> y;
      bool ok = false;
      for(pair<string, P> item : database) {
        if(item.second.first <= y && y <= item.second.second) {
          ok = true;
          cout << item.first << ' ' << (y - item.second.first + 1) << endl;
        }
      }
      
      if(!ok) {
        cout << "Unknown" << endl;
      }
    }
  }
}

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

typedef struct{
    string n;
    int a, b;
}data;

int main(){
    int n, q;
    data d[1001];
    while(cin >> n >> q, n||q){
        rep(i,n){
            string s;
            int a, b;
            cin >> s >> a >> b;
            d[i].n = s;
            d[i].a = b - a + 1;
            d[i].b = b;
        }
        rep(i,q){
            int a;
            bool f = true;
            cin >> a;
            rep(j,n){
                if(a >= d[j].a && a <= d[j].b){
                    cout << d[i].n << ' ' << a - d[j].a + 1 << endl;
                    f = false;
                    break;
                }
            }
            if(f) cout << "Unknown" << endl;
        }
    }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<string, P> PSP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
  cin.sync_with_stdio(false);
  int n, q;
  while(cin >> n >> q, n | q) {
    vector<PSP> v(n);
    rep(i, n) {
      cin >> v[i].fi;
      int tmp;
      cin >> tmp >> v[i].se.se;
      v[i].se.fi = v[i].se.se - tmp + 1;
    }

    rep(i, q) {
      int y;
      cin >> y;
      string ans = "Unknown";
      rep(i, n) {
        if (v[i].se.fi <= y && y <= v[i].se.se) {
          ans = v[i].fi + " " + to_string(y - v[i].se.fi + 1);
          break;
        }
      }
      cout << ans << endl;
    }
  }


  return 0;
}

C++: #include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
struct Data {
	string name;
	int start, max;
	bool operator <(Data b) {
		return this->start < b.start;
	}
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, q;
		cin >> n >> q;
		if (!n)break;
		vector<Data> v(n);
		REP(i, n) {
			cin >> v[i].name >> v[i].max >> v[i].start;
			v[i].start -= v[i].max - 1;
		}
		sort(ALL(v));
		REP(i, q) {
			int a;
			cin >> a;
			int p = -1;
			REP(j, n) {
				if (v[j].start <= a&&v[j].start+v[j].max-1>=a) {
					p = j;
					cout << v[j].name << endl;
					break;
				}
			}
			if (p == -1) {
				cout << "Unknown" << endl;
			}
			


		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#define lli long long int

using namespace std;

struct info{
	string era;
	lli eby;
	lli wy;
};

bool comp(const info& i1, const info& i2)
{
	return i1.wy < i2.wy;
}

int main()
{
	int n, q;
	info a[1001];
	lli p;
	
	while(1){
		cin >> n >> q;
		if(n == 0 && q == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			cin >> a[i].era >> a[i].eby >> a[i].wy;
		}
		sort(a, a+n, comp);
		
		for(int i = 0; i < q; i++){
			cin >> p;
			bool f = true;
			for(int j = 0; j < n; j++){
				lli t = (a[j].eby+p)-a[j].wy;
				if(t > 0 && a[j].wy >= p){
					cout << a[j].era << " " << t << endl;
					f = false;
					break;
				}
			}
			if(f){
				cout << "Unknown" << endl;
			}
		}
	}
	
	return 0;
}

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

using namespace std;

typedef long long LL;

int main()
{
    int N, Q;

    while (cin >> N >> Q, N || Q) {
        vector<pair<LL, string> > memo;

        for (int i = 0; i < N; i++) {
            string s;
            LL ey, wy;

            cin >> s >> ey >> wy;
            memo.push_back(make_pair(wy - ey, s));
        }
        sort(memo.begin(), memo.end());

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

            cin >> q;
            bool flag = false;
            vector<pair<LL, string> >::iterator it = memo.begin();

            while (it != memo.end()) {
                if ((*it).first > q && memo.size() > 1) {
                    advance(it, -1);
                    flag = true;
                    cout << (*it).second << " " << q - (*it).first << endl;
                    break;
                }

                it++;
            }
            if (!flag)
                cout << "Unknown" << endl;
        }
    }

    return 0;
}