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 <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int main(){
    for (;;) {
        int n,q;
        cin >> n>> q;
        if (!n and !q) {
            break;
        }
        map<string, int> cal;
        vector<string> re(1002);
        int ans[1002][2];
        memset(ans, 0, sizeof(ans));
        int pa=1;
        for (int i=0; i<n; i++) {
            string s;
            int a,b;
            cin >> s >> b >> a;
            if (cal[s]==0){
                re[pa]=s;
                cal[s]=pa;
                ans[cal[s]][0]=a-b+1;
                ans[cal[s]][1]=a;
                pa++;
            }else{
                ans[cal[s]][0]=min(a-b+1,ans[cal[s]][0]);
                ans[cal[s]][1]=max(a,ans[cal[s]][1]);
            }
        }
        for (int i=0; i<q; i++) {
            int y;
            cin >> y;
            int ch = 0;
            for (int i=1; i<=n;i++) {
                int a = ans[i][0], b = ans[i][1];
                if (a<= y and y <= b) {
                    cout << re[i] <<" "<< y-ans[i][0]+1<< endl;
                    ch++;
                    break;
                }
            }
            if(ch == 0) cout <<"Unknown"<<endl;
            
        }
    }
}

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, q;

struct era{
	string name;
	int by, y;
	era(string _name, int _by, int _y) : name(_name), by(_by), y(_y){}
};

vector<era> v;

int main(){
	while (cin >> n >> q&&n+q){
		v.clear();
		REP(i, n){
			string s;
			int by, y;
			cin >> s >> by >> y;
			v.push_back(era(s, by, y));
		}
		REP(i, q){
			int y;
			bool f = 1;
			cin >> y;
			REP(j, v.size()){
				if (v[j].y - y <= v[j].by - 1 && v[j].y - y >= 0){
					cout << v[j].name << " " << v[j].by - (v[j].y - y) << endl;
					break;
				}
				if (j == v.size() - 1)cout << "Unknown" << endl;
			}
		}
	}
}