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>
using namespace std;
int n, q;
pair<int, pair<int, string> > eras[1000];

void solve(int x) {
	for (int i = 0; i < n; i++) {
		if (eras[i].first < x && x <= eras[i].second.first) {
			cout << eras[i].second.second << ' ' << x - eras[i].first << endl;
			return;
		}
	}
	cout << "Unknown" << endl;
}

int main () {
	while (cin >> n >> q, n || q) {
		for (int i = 0; i < n; i++) {
			string name;
			int eby, wy;
			cin >> name >> eby >> wy;
			eras[i] = make_pair(wy - eby, make_pair(wy, name));
		}
		sort(eras, eras + n);
		for (int i = 0; i < q; i++) {
			int x;
			cin >> x;
			solve(x);
		}
	}
	return 0;
}

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

int main() {
  int n,m;
  while(cin >> n >> m && n) {
    string s[n];
    int x[n],y[n];
    for(int i=0; i<n; i++) cin >> s[i] >> x[i] >> y[i];
    while(m--) {
      int t;
      cin >> t;
      for(int i=0; i<n; i++) {
        if(y[i]-x[i]<t&&t<=y[i]) {
          cout << s[i] << " " << t-y[i]+x[i] << endl;
          goto next;
        }
      }
      cout << "Unknown" << endl;
    next:;
    }
  }
  return 0;
}

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

using namespace std;

struct DATA{
  string era;
  int x;
  int year;
};

bool Compare(const DATA&, const DATA&);

int main(){
  int i, j, n, m, x, y, ans;
  string s;
  DATA _data;
  vector<DATA> data;

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    for(i=0; i<n; ++i){
      cin >> s >> x >> y;
      _data.era = s;
      _data.x = x;
      _data.year = y;
      data.push_back(_data);
    }
    sort(data.begin(), data.end(), Compare);

    for(i=0; i<m; ++i){
      cin >> x;

      for(j=0, y=-1; j<data.size(); ++j){
	if(x <= data[j].year){
	  y = j;
	  break;
	}
      }

      if(y == -1){
	cout << "Unknown" << endl;
      }else{
	if(x > data[y].year-data[y].x){
	  ans = data[y].x - data[y].year + x;
	  cout << data[y].era << " " << ans << endl;
	}else{
	  cout << "Unknown" << endl;
	}
      }
    }

    data.clear();
  }
  return 0;
}

bool Compare(const DATA& x, const DATA& y){
  return (x.year < y.year);
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,m;
    while(cin>>n>>m,n+m){
        map<string,pii>mp;
        rep(i,n){
            string hoge;
            cin>>hoge;
            int a,b; cin>>a>>b;
            mp[hoge]=pii(b-a+1,b);
        }
        rep(_,m){
            int tiya;cin>>tiya;
            bool flag=true;
            for(map<string,pii>::iterator itr=mp.begin();itr!=mp.end();itr++){
                if(itr->second.first<=tiya&&tiya<=itr->second.second){
                    flag=false;
                    cout<<(itr->first)<<" "<<tiya-itr->second.first+1<<endl;
                    break;
                }
            }
            if(flag)cout<<"Unknown"<<endl;
        }
    }
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j;
  int n,q;
  while(1){
    cin>>n>>q;
    if(n+q==0)break;
    vector<pair<pii,string> > p(n);
    rep(i,n){
      int a,b;
      cin>>p[i].second>>a>>b;
      p[i].first.first=b-a+1;
      p[i].first.second=b;
    }
    sort(all(p));
    rep(i,q){
      int y;
      cin>>y;
      rep(j,n)
    if(p[j].first.first<=y && y<=p[j].first.second){
      cout<<p[j].second<<" "<<y-p[j].first.first+1<<endl;
      break;
    }
      if(j==n)cout<<"Unknown"<<endl;
    }
  }
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<ll, ll> P;
int main()
{
  int N, Q;
  while(cin>>N>>Q,N||Q) {
    map<P, string> MAP;
    FOR(i,0,N) {
      string s;
      ll a, b;
      cin >> s >> a >> b;
      MAP[P(a, b)] = s;
    }
    FOR(i,0,Q) {
      ll in; cin >> in;
      bool ok = false;
      for(auto m : MAP) {
        ll end = m.first.second;
        ll start = end - m.first.first + 1;
        if(in >= start && in <= end) {
          ok = true;
          cout << m.second << " " << in - start + 1 << endl;
        }
      }
      if(!ok) {
        puts("Unknown");
      }
    }
  }
  return 0;
}