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 pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n, q; cin >> n >> q;
    if(n == 0 && q == 0) break;

    map<string, P> m;
    REP(i, n) {
      string en; cin >> en;
      int ey, wy; cin >> ey >> wy;
      m[en] = make_pair(wy - ey + 1, wy);
    }

    REP(i, q) {
      int t; cin >> t;
      string name = "Unknown";
      int year = 0;
      MFOR(j, m) {
        if(j->second.first <= t && t <= j->second.second) {
          name = j->first;
          year = t - j->second.first + 1;
          break;
        }
      }
      if(name == "Unknown") cout << name << endl;
      else cout << name << " " << year << endl;
    }
  }
}

C++: #include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
#define INF 1000000000000LL
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<long, long> pll;
typedef pair<pll, string> pls;

int N, Q, Y, W;
string Name;
pls E[1000];

int main(void) {
  while(cin >> N >> Q, N || Q) {
    REP(i, 0, N) {
      cin >> Name >> Y >> W;
      E[i] = pls(pll(W - Y + 1, Y), Name);
    }
    E[N] = pls(pll(INF, 0), "");

    sort(E, E + N);

    REP(i, 0, Q) {
      int q; cin >> q;
      if(q < E[0].fi.fi) {
        cout << "Unknown" << endl;
        continue;
      }
      REP(j, 0, N) {
        if(E[j].fi.fi <= q && q < E[j + 1].fi.fi) {
          int ans = q - E[j].fi.fi + 1;
          if(ans <= E[j].fi.se) {
            cout << E[j].se << " " << ans << endl;
            goto END;
          }
        }
      }
      cout << "Unknown" << endl;
END:;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n, m;
    while(cin >> n >> m, n || m) {
        map<string, pii> mp;
        rep(i,0,n) {
            string s; int a, b;
            cin >> s >> a >> b;
            int st = b - a + 1;
            mp[s] = pii(st, b);
        }
        rep(i,0,m) {
            int inp; cin >> inp;
            bool ok = false;
            for(auto x : mp) {
                int s = x.second.first;
                int t = x.second.second;
                if(s <= inp && inp <= t) {
                    int year = inp - s + 1;
                    cout << x.first << " " << year << endl;
                    ok = true;
                    break;
                }
            }
            if(!ok) cout << "Unknown" << endl;
        }
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;string S[9999],U;int n,a,b,c,d,p[9999][2],i,j;int main(){while(1){cin>>a>>b;if(!a){break;}for(i=0;i<a;i++){cin>>U>>c>>d;S[i]=U;p[i][0]=d-c+1;p[i][1]=d;}for(i=0;i<b;i++){cin>>c;for(j=0;j<a;j++){if(c>=p[j][0]&&c<=p[j][1]){cout<<S[j]<<' '<<c-p[j][0]+1<<endl;goto E;}}printf("Unknown\n");E:;}}}

C++: #include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
using namespace std;
using T = tuple<int,int,string>;
vector<T> V;
int main(){
    int N,Q;
    while(cin>>N>>Q,N){
        V.clear();
        for(int i=0;i<N;i++){
            string name;
            int era, west;
            cin>>name>>era>>west;
            V.emplace_back(west,era,name);
        }
        sort(V.begin(), V.end());
        for(int i=0;i<Q;i++){
            int query;
            cin>>query;
            auto lb = lower_bound(V.begin(), V.end(), T(query,0,""));
            if(lb==V.end()){
                cout<<"Unknown"<<endl;
            }else{
                string name;
                int era,west;
                tie(west,era,name) = *lb;
                if(query<west-era+1){
                    cout<<"Unknown"<<endl;
                }else{
                    cout<<name<<' '<<era-(west-query)<<endl;
                }
            }
        }
    }
    return 0;
}