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 <fstream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <complex>
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
using namespace std;

struct Era {
  string name;
  int base,len;
};

int main()
{
  ifstream ifs("A.txt");
  ofstream ofs();
  int n,q;

  while(ifs>>n>>q, n|q) {
    string s;
    int base,wes;
    vector<Era> v;
    REP(i,n) {
      ifs>>s>>base>>wes;
      Era e;
      e.name = s;
      e.base = base;
      e.len = wes;
      v.push_back(e);
    }

    int query;
    REP(i,q) {
      ifs>>query;
      //cout<<"query "<<query<<endl;
      for(int j=0; j<v.size(); ++j) {
        if(v[j].len-v[j].base+1 <= query && v[j].len >= query) {
          cout<<v[j].name<<" "<<query-(v[j].len-v[j].base)<<endl;

          //cout<<v[j].len<<" "<<v[j].base<<endl;
          goto NEXT;
        }
        //cout<<v[j].name<<" "<<query<<" "<<v[j].len-base+1<<" "<<v[j].len<<endl;
      }
      cout<<"Unknown"<<endl;
    NEXT:;
    }
  }

}

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

struct Y{
  string n; int b,e;
  Y(void){}
  Y(string a,int x,int y):n(a),b(x),e(y){}
  bool operator<(const Y a)const{return b<a.b;}
};

int main(){
  int n,q,i;
  int a,b,y;
  string name;
  Y e[1010];

  while(cin >> n >> q, n+q){
    for(i=0;i<n;i++){
      cin >> name >> a >> b;
      e[i] = Y(name,b-a+1,b);
    }
    sort(e,e+n);
    for(i=0;i<q;i++){
      cin >> y;
      int l=-1,r=n;
      while(r-l>1){
	int m = (l+r)/2;
	if(e[m].e>=y)r = m;
	else l = m;
      }

      if(r==n || e[r].b>y)cout << "Unknown\n";
      else cout << e[r].n << " " << y-e[r].b+1 << endl;
    }
  }
}

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


class Era{
public:
  string name;
  int s,e;
  
  bool operator<(const Era & e)const{
    return s < e.s;
  }

  Era(string str,int a,int b):name(str),s(a),e(b){}
  Era();
};

Era:: Era(){
}


void func(vector<Era>& era,int n){
  int a;
  cin >> a;
  for(int i = 0 ; i < n ; i++){
    if(era[i].s < a && a <= era[i].e){
      cout << era[i].name << ' ' << a - era[i].s << endl;
      return ;
    }
  }
  cout << "Unknown" << endl;
  return;
}


int main(){
  int n,q;
  while(1){
    cin >> n >> q;
    if(n == 0 && q == 0)break;
    vector<Era> era(n);
    for(int i = 0 ;i < n ;i++){
      string str;
      int a,b;
      cin >> str >> a >> b;
      era[i] = Era(str,b-a,b);
    }
    sort(era.begin(), era.end());
    for(int i = 0 ; i < q ; i++){
      func(era,n);
    }
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
struct po{
  string str;
  int era,end;
};

int main() {
  while(1){
    int n,m;
    cin >> n >> m;
    if(n==0 && m == 0) break;
    
    po ls[1001];
    for(int i=0;i<n;i++){
      cin >> ls[i].str >>  ls[i].end >> ls[i].era;
      ls[i].era -= (ls[i].end-1);
    }
    for(int i=0;i<m;i++) {
      int a,flg = 0;
      cin >> a;
      for(int i=0;i<n-1;i++) 
	if(ls[i].era<=a && a <ls[i+1].era) {
	  if(ls[i].end >= a-ls[i].era+1)cout << ls[i].str <<" "<<a-ls[i].era+1<<endl,flg=1;
	  break;
	}
      if(flg == 0 && ls[n-1].era <= a && ls[n-1].end<=a-ls[n-1].end+1) 
	 cout << ls[n-1].str << " "<< a-ls[n-1].era+1 <<endl,flg = 1;
      if(flg == 0) cout <<"Unknown"<<endl;
    }
  }
  return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	for (int N, Q; cin >> N >> Q&&N;) {
		vector<pair<int, string>> v(N);
		rep(i, 0, N) {
			string s; int a, b;
			cin >> s >> a >> b;
			v[i].first = b - a;
			v[i].second = s;
		}
		sort(all(v));
		rep(i, 0, Q) {
			int a; cin >> a;
			int e = -1;
			rep(j, 0, N) {
				if (a <= v[j].first) {
					e = j - 1;
					break;
				}
			}
			if (e == -1 || a == v[e + 1].first) {
				cout << "Unknown" << endl;
			}
			else {
				cout << v[e].second << " " << a - v[e].first << endl;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <map>
#define inf 1e9
#define eps 1e-8
#define MAXT 500000
#define MAXN 1010
using namespace std;

int n,q;
struct Node
{
    char nam[20];
    int st,ed;
    int id;
}a[MAXN];
int main()
{
    while(scanf("%d%d",&n,&q))
    {
        if(n==0&&q==0)break;
        for(int i=1;i<=n;i++)
        {
            scanf("%s",a[i].nam);
            int x,y;
            scanf("%d%d",&x,&y);
            a[i].st=y-x+1;a[i].ed=y;
        }
        while(q--)
        {
            int tp;
            scanf("%d",&tp);
            int flag=0;
            for(int i=1;i<=n;i++)
            {
                if(tp>=a[i].st&&tp<=a[i].ed)
                {
                    printf("%s %d\n",a[i].nam,tp-a[i].st+1);
                    flag=1;
                    break;
                }
            }
            if(!flag)printf("Unknown\n");
        }
    }
    return 0;
}

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

using namespace std;

int main()
{
    int N, Q;

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

        for (int i = 0; i < N; i++) {
            string s;
            int 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++) {
            int q;

            cin >> q;
            bool flag = false;
            vector<pair<int, 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;
}