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>
#define ll long long
using namespace std;

struct info {
    string name;
    int s, e;
    info(string _name, int by, int wy) {
        name = _name;
        s = wy - by;
        e = wy;
    }
    bool operator<(const info& another) { 
        return s < another.s;
    }
};

int main() {
    int n, q;
    while (cin >> n >> q, n | q) {
        vector<info> v;
        for (int i = 0; i < n; i++) {
            string s;
            int by, wy;
            cin >> s >> by >> wy;
            v.push_back(info(s, by, wy));
        }
        sort(v.begin(), v.end());
        for (int i = 0; i < q; i++) {
            int y, f = 1;
            cin >> y;
            for(int i = 0; i < v.size(); i++){
                if(v[i].s < y && y <= v[i].e){
                    cout << v[i].name << " " << y - v[i].s << endl;
                    f = 0;
                    break;
                }
            }
            if(f) cout << "Unknown" << endl;
        }
    }
    return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define sy first.first
#define ey first.second
#define nm second

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n, q; cin >> n >> q, n;){
        vector< pair<pii, string> > years(n);
        rep(i, n){
            string name;
            int eby, wy;
            cin >> name >> eby >> wy;

            years[i] = mp(mp(wy - eby + 1, wy), name);
        }
        sort(all(years));

        rep(i, q){
            int y; cin >> y;

            bool ok = false;
            rep(j, n){
                if(years[j].sy <= y && y <= years[j].ey){
                    cout << years[j].nm << " " << y - years[j].sy + 1 << endl;
                    ok = true;
                    break;
                }
            }
            if(!ok) cout << "Unknown" << endl;
        }
    }

	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

struct NENDAI {
    string name;
    int start;
    int end;

    NENDAI(){}
    NENDAI(string name0, int base, int west) {
        name = name0;
        start = west - base + 1;
        end = west;
    }
};

int main(void) {
    while (1) {
        int n;
        int q;
        cin >> n >> q;
        if (n == 0 && q == 0) {
            break;
        }
        Vec<NENDAI> list(n);
        for (int i = 0; i < n; i++) {
            string name;
            int base;
            int west;
            cin >> name >> base >> west;
            NENDAI nendai(name, base, west);
            list[i] = nendai;
        }
        for (int i = 0; i < q; i++) {
            int toi;
            cin >> toi;
            bool found = false;
            for (int j = 0; j < n; j++) {
                if (toi >= list[j].start && toi <= list[j].end) {
                    cout << list[j].name << " " << toi - list[j].start + 1 <<endl;
                    found = true;
                    break;
                }
            }
            if (found == false) {
                cout << "Unknown" << endl;
            }
        }
    }
    return 0;
}

C++: #include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
//typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x, int y):x(x), y(y){}
	P(){}
};

/** Problem2242 : Era Name **/
struct Era {
	int s, e;
	string name;
	Era(int _s, int _e, string _name):s(_s), e(_e), name(_name){}
	Era(){}
};

int main()
{
	int N, M;
	while (cin>>N>>M, N||M) {
	
		vector<Era> era(N);
		rep(i, N) {
			int a, b;
			cin>>era[i].name>>a>>b;
			era[i].e = b;
			era[i].s = b-a+1;
		}
	
		rep(i, M) {
			int a; cin>>a;
			bool ok=false;
			rep(j, N) {
				if (era[j].s <= a && a <= era[j].e) {
					cout << era[j].name << " " << a-era[j].s+1 << endl;
					ok=true;
					break;
				}
			}
			if (!ok)
				cout << "Unknown" << endl;
		}
	}
}