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;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

bool comp(tuple<ll,ll,string> a,tuple<ll,ll,string> b){
	return (get<1>(a) < get<1>(b));
}

void solve(int n,int q){
	vector<tuple<ll,ll,string>> v(n);
	ll x,y;
	rep(i,n){
		cin>>get<2>(v[i])>>x>>y;
		get<0>(v[i])=y-x+1;
		get<1>(v[i])=y;
	}
	sort(all(v),[](auto &a,auto &b){
		return get<0>(a)<get<0>(b);
	});
	v.push_back(tuple<ll,ll,string>(LINF,LINF+1,""));
	while(q--){
		cin>>x;
		tuple<ll,ll,string> z=make_tuple(0ll,x,"");
		auto itr=lower_bound(all(v),z,comp);
		if(get<0>(*itr)<=x&&itr!=v.end()-1){
			cout<<get<2>(*itr)<<" "<<x-get<0>(*itr)+1<<"\n";
		}
		else{
			cout<<"Unknown\n";
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,q;
	while(cin>>n>>q,n)solve(n,q);
}

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

int main(){
    int n;
    int q;
    while(cin>>n>>q,n){
        vector<tuple<int,int,string>> eras(n);
        for(int i=0;i<n;i++){
            string eraname;
            int eray;
            int wesy;
            cin>>eraname>>eray>>wesy;
            int startwes=wesy-eray+1;
            int endwes=wesy;
            eras[i]=make_tuple(startwes,endwes,eraname);
        }
        sort(eras.begin(),eras.end());
        for(int i=0;i<q;i++){
            int year;
            cin>>year;
            for(int j=0;j<=eras.size();j++){
                if(eras.size()<=j){
                    cout<<"Unknown"<<endl;
                    break;
                }
                if(get<0>(eras[i])<= year && year<=get<1>(eras[i])){
                    cout<<get<2>(eras[i])<<" "<<year-get<0>(eras[i])+1<<endl;
                    break;
                }


            }



        }
    }

    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n,q;
	while(scanf("%d%d",&n,&q),n){
		map<int,string>mp;
		rep(i,n){
			string s;
			int j,k;
			cin>>s>>j>>k;
			mp[k-j]=s;
		}
		rep(i,q){
			int d;scanf("%d",&d);
			if(d<=(*mp.begin()).first){
				puts("Unknown");
				continue;
			}
			auto it=mp.lower_bound(d);
			if((*it).first==d)puts("Unknown");
			else{
				it--;
				cout<<(*it).second<<' '<<d-(*it).first<<endl;
			}
		}
	}
}

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

using namespace std;

int N,Q;
struct data{
  string name;
  int start,end;
};
vector<data> V;


void init(){
  V.clear();
}

void solve(int n){
  for(int i = 0; i < V.size(); i++){
    if(V[i].start <= n && n <= V[i].end){
      cout << V[i].name << " " << n-V[i].start+1 << endl;
      return;
    }
  }
  cout << "Unknown" << endl;
}

int main(){
  while(cin >> N >> Q && N+Q){
    init();
    for(int i = 0; i < N; i++){
      data d;
      int a,b;
      cin >> d.name >> a >> b;
      d.start = b-a+1;
      d.end = b;
      V.push_back(d);
    }

    for(int i = 0; i < Q; i++){
      int num;
      cin >> num;
      solve(num);
    }
  }
  
  return 0;
}

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

int N,Q;
string s[1000];
int a[1000];
int b[1000];

void solve(int m){
  for(int i=0;i<N;i++){
    if(b[i]-a[i]<m&&m<=b[i]){
      cout<<s[i]<<' '<<a[i]-(b[i]-m)<<endl;
      return;
    }
  }
  cout<<"Unknown"<<endl;
}

int main(){
  while(1){
    cin>>N>>Q;
    if(N==0&&Q==0)break;
    for(int i=0;i<N;i++){
      cin>>s[i]>>a[i]>>b[i];
    }
    for(int i=0;i<Q;i++){
      int m;
      cin>>m;
      solve(m);
    }
  }
  return 0;
}