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<cstdio>
#include<string>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<iostream>
#include<math.h>
#include<map>
typedef long long ll;
#define eps 1e-8
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
using namespace std;
char na[2000][30];
struct node
{
    ll z,id,flag;
} a[3000];

int cmp(node a,node b)
{
    return a.z<b.z;
}
ll id;
node find(ll t,ll l,ll r)
{

    while(l<=r)
    {
        ll mi=(l+r)/2;
        if(a[mi].z<t)
        {
            id=mi;
            l=mi+1;
        }
        else if(a[mi].z==t)
        {
            id=mi;
            return a[mi];
        }
        else
            r=mi-1;
    }
    return a[id];
}
int main()
{
   // freopen("f:\\in.txt","r",stdin);
    ll n,m;
    while(scanf("%lld%lld",&n,&m)!=EOF&&n!=0)
    {
        int cnt=0;
        for(int i=0; i<n; i++)
        {
            ll t,r;
            scanf("%s%lld%lld",na[i],&t,&r);
            a[cnt].id=i;
            a[cnt].z=r-t+1;
            a[cnt++].flag=-1;
            a[cnt].id=i;
            a[cnt].z=r;
            a[cnt++].flag=1;
        }
        sort(a,a+cnt,cmp);
        for(int i=0; i<m; i++)
        {
            ll t;
            scanf("%lld",&t);
            node now=find(t,0,cnt-1);
            if(now.flag==1&&t!=now.z)
                printf("Unknown\n");
            else
            {
                if(now.flag==1&&t==now.z)
                {
                    printf("%s %lld\n",na[now.id],t-a[id-1].z+1);
                }
                else
                    printf("%s %lld\n",na[now.id],t-now.z+1);
            }
        }
    }
    return 0;
}

C++: #include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int N, Q, A, B, R; pair<int, string> D[1000];
int main() {
	while (true) {
		scanf("%d%d", &N, &Q);
		if (N == 0 && Q == 0) break;
		for (int i = 0; i < N; i++) cin >> D[i].second >> A >> B, D[i].first = B - A;
		sort(D, D + N);
		for (int i = 0; i < Q; i++) {
			scanf("%d", &R);
			bool flag = false;
			for (int j = N - 1; j >= 0; j++) {
				if (D[i].first < R) {
					printf("%s %d\n", D[i].second, R - D[i].first); flag = true; break;
				}
			}
			if (!flag) {
				printf("Unknown\n");
			}
		}
	}
	return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct Era{
  string str;
  LL dur, year;
  bool operator<(const Era& rhs)const{
	return year < rhs.year;
  }
};

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, Q;
  while(cin>>N>>Q,N){
	vector<Era> eras(N);
	REP(i,N)
	  cin >> eras[i].str >> eras[i].dur >> eras[i].year;
	SORT(eras);
	REP(i,Q){
	  Era dummy;
	  cin >> dummy.year;
	  auto it = lower_bound(eras.begin(), eras.end(), dummy);
	  if(it == eras.end())
		cout << "Unknown" << endl;
	  else{
		int ans = dummy.year - (it->year - it->dur);
		if(ans <= 0)
		  cout << "Unknown" << endl;
		else
		  cout << it->str << " " << ans << endl;
	  }
	}
  }
  
  return 0;
}

C++: #include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  for(;;){
    int n,q;
    cin >> n >> q;
    if(!n&&!q) return 0;
    vector<pair<pair<int,int>,string> > tape;
    // (a,b] a<y,y<=b
    REP(i,n){
      string era;
      int th,y;
      cin >> era >> th >> y;
      tape.push_back(make_pair(make_pair(y-th,y),era));
    }
    SORT(tape);
    REP(i,q){
      int y;
      cin >> y;
      int j;
      for(j=0;j<tape.size();++j) if(tape[j].first.first<y&&y<=tape[j].first.second) break;
      if(j<tape.size()) cout << tape[j].second << ' ' << y-tape[j].first.first << endl;
      else cout << "Unknown" << endl;
    }
  }
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

typedef pair<int, pair<string, int> > P;

#define INF 1000000000

int main(){
    int n,q;
    while(scanf("%d %d", &n, &q), n|q){
        vector<P> vec;
        rep(i,n){
            int y1,y2;
            char c[20];
            scanf("%s %d %d", c, &y1, &y2);
            string s(c);
            vec.pb(mp(y2, mp(s, y1)));
            vec.pb(mp(y2-y1+1, mp(s,1)));
        }

        sort(all(vec));
        vec.erase(unique(all(vec)), vec.end());

        rep(i,q){
            int query;
            cin>>query;
            P que = mp(query, mp("",0));
            auto itr = lower_bound(all(vec), que);

            const string uk = "Unknown";
            if(itr==vec.end()){
                cout<<uk<<endl;
                continue;
            }
            if(itr->second.second==1){
                if(itr->first == query)
                    cout<<itr->second.first<<" 1"<<endl;
                else
                    cout<<uk<<endl;
            } else {
                itr--;
                int year = query - itr->first +1;
                cout<<itr->second.first<<" "<<year<<endl;
            }

        }

    }

    return 0;
}