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<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a||b){
    map<int,string>in;
    map<int,int>in1;
    rep(q,a){
      string s;
      int c,d;
      cin>>s>>c>>d;
      loop(i,d-c+1,d+1){
	in[i]=s;
	in1[i]=i-d+c;
      }
    }
    rep(q,b){
      int n;
      cin>>n;
      if(in1[n])
	cout<<in[n]<<" "<<in1[n]<<endl;
      else cout<<"Unknown"<<endl;
    }
  }
}

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()
{

  int n,q;

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

    int query;
    REP(i,q) {
      cin>>query;
      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;
          goto NEXT;
        }
      }
      cout<<"Unknown"<<endl;
    NEXT:;
    }
  }

}

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2242

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

struct Era{

	int from;
	int to;
	string name;

	Era(string era, int w,int g): name(era),from(g - w),to(g){}

	bool isEra(int g){
		return from < g && g <= to;
	}

	void print(int g){
		cout << name << " " << g - from << endl;
	}
};

int main()
{
	int N,Q;
	
	while(cin >> N >> Q && N)
	{
		vector<Era> eras;

		string name;
		int year_w, year_g;
		rep(nth,N)
		{
			cin >> name >> year_w >> year_g;
			eras.push_back(Era(name,year_w, year_g));
		}

		int q;
		rep(nth, Q)
		{
			cin >> q;
			
			bool flag=false;
			rep(i,eras.size())
			{
				if(eras[i].isEra(q))
				{
					eras[i].print(q);
					flag = true;
					break;
				}
			}
			if(!flag){ cout << "Unknown" << endl; }
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    while (1) {
        int n, q;
        cin >> n >> q;
        if (n == 0 && q == 0) return 0;
        
        vector<pair<int, string> > nengo;
        for (int i = 0; i < n; i++) {
            string s;
            int ny, wy;
            cin >> s >> ny >> wy;
            nengo.emplace_back(wy - (ny - 1), s);
            nengo.emplace_back(wy, "{");
        }
        sort(nengo.begin(), nengo.end());
        
        for (int i = 0; i < q; i++) {
            int qy, in = 0;
            bool output = false;
            cin >> qy;
            for (int j = 0; j < nengo.size(); j++) {
                if (nengo[j].first < qy) {
                    if (nengo[j].second == "{") in--;
                    else in++;
                }
                else if (nengo[j].first == qy && nengo[j].second != "{") in++;
                else {
                    if (in == 0) cout << "Unknown" << endl;
                    else cout << nengo[j - 1].second << " " << qy + 1 - nengo[j - 1].first << endl;
                    output = true;
                    break;
                }
            }
            if (!output) cout << "Unknown" << endl;
            
        }
    }
}

C++: #include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

tuple<int, int, string> era[1024];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int N, Q;
    cin >> N >> Q;
    if (N == 0 && Q == 0) break;
    REP(i, N) {
      string en;
      int eby, wy;
      cin >> en >> eby >> wy;
      era[i] = make_tuple(wy - eby + 1, wy, en);
    }

    REP(_, Q) {
      int q;
      cin >> q;
      bool flag = true;
      REP(i, N) {
	int es, ee;
	string en;
	tie(es, ee, en) = era[i];
	if (es <= q && q <= ee) {
	  cout << en << ' ' << q - es + 1 << endl;
	  flag = false;
	  break;
	}
      }
      if (flag) {
	cout << "Unknown" << endl;
      }
    }
  }			    
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

map<string, P> mp;

int main(){
	int n, q;
	string name;
	int num;
	int year;
	while(cin >> n >> q && (n || q)){
		mp.clear();
		for(int i = 0; i < n; i++){
			cin >> name >> num >> year;
			mp[name] = make_pair(num, year);
		}
		for(int i = 0; i < q; i++){
			cin >> year;
			bool f = false;
			for(map<string, P>::iterator iter = mp.begin();
				iter != mp.end(); iter++)
			{
				P p = (*iter).second;
				if(year <= p.second && year > p.second - p.first){
					f = true;
					cout << (*iter).first << " " << year - (p.second - p.first) << endl;
				}
			}
			if(!f) cout << "Unknown" << endl;
		}
	}
	return 0;
}