Language: C++

/*
 * Package: StandardCodeLibrary.Core
 * */
//蠑戊ソ帛クク逕ィ逧?、エ譁?サカ蟷カ菴ソ逕ィstd蜷榊ュ礼ゥコ髣エ
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <utility>
#include <vector>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <climits>
using namespace std;

//逕ィ莠主?蟆台サ」遐??逧?ョ?#define lp for(;;)
#define repf(i,a,b) for (int i=(a);i<(b);++i)
#define rrepf(i,a,b) for (int i=(a)-1;i>=(b);--i)
#define rep(i,n) repf(i,0,n)
#define rrep(i,n) rrepf(i,n,0)
#define ft(i,a,b) for (int i=(a);i<=(b);++i)
#define fdt(i,a,b) for (int i=(a);i>=(b);--i)
#define for_nonempty_subsets(subset,set) for (int subset=set;subset;subset=(subset-1)&(set))
#define for_in_charset(i,charset) for (cstr i=(charset);*i;i++)
#define whl while
#define rtn return
#define fl(x,y) memset((x),char(y),sizeof(x))
#define clr(x) fl(x,char(0))
#define cpy(x,y) memcpy(x,y,sizeof(x))
#define sf scanf
#define pf printf
#define vec vector
#define pr pair
#define que queue
#define prq priority_queue
#define itr iterator
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ins insert
#define ers erase
#define lb lower_bound
#define ub upper_bound
#define rnk order_of_key
#define sel find_by_order
#define sz(x) (int((x).size()))
#define all(x) (x).begin(),(x).end()
#define srt(x) sort(all(x))
#define uniq(x) srt(x),(x).erase(unique(all(x)),(x).end())
#define rev(x) reverse(all(x))
#define shf(x) random_shuffle(all(x))
#define nxtp(x) next_permutation(all(x))

//隹?ッ慕嶌蜈ウ逧?ョ?#ifndef DEBUG
#define prt(x) (cerr)
#define asrtWA(s) do if(!(s))exit(0);whl(0)
#define asrtTLE(s) do if(!(s))whl(1);whl(0)
#define asrtMLE(s) do if(!(s))whl(new int);whl(0)
#define asrtOLE(s) do if(!(s))whl(1)puts("OLE");whl(0)
#define asrtRE(s) do if(!(s))*(int*)0=0;whl(0)
#define runtime() (cerr)
#define input(in) freopen(in,"r",stdin)
#define output(out) freopen(out,"w",stdout)
#else
#define prt(x) cerr<<"隨ャ"<<__LINE__<<"陦圭t: "<<#x"\t="<<(x)<<endl
#define asrtWA(s) do if(!(s))cerr<<"assert("#s")"<<endl;whl(0)
#define asrtTLE(s) do if(!(s))cerr<<"assert("#s")"<<endl;whl(0)
#define asrtMLE(s) do if(!(s))cerr<<"assert("#s")"<<endl;whl(0)
#define asrtOLE(s) do if(!(s))cerr<<"assert("#s")"<<endl;whl(0)
#define asrtRE(s) do if(!(s))cerr<<"assert("#s")"<<endl;whl(0)
#define runtime() cerr<<"Used: "<<db(clock())/CLOCKS_PER_SEC<<"s"<<endl
#define input(in)
#define output(out)
#endif

//蟶ク逕ィ謨ー謐ョ邀サ蝙?typedef long long int lli;
typedef double db;
typedef const char* cstr;
typedef string str;
typedef vec<int> vi;
typedef vec<vi> vvi;
typedef vec<bool> vb;
typedef vec<vb> vvb;
typedef vec<str> vs;
typedef pr<int,int> pii;
typedef pr<lli,lli> pll;
typedef pr<db,db> pdd;
typedef map<int,int> mii;
typedef map<str,int> msi;
typedef map<char,int> mci;
typedef set<int> si;
typedef set<str> ss;
typedef que<int> qi;
typedef vec<pii> vpii;
typedef vec<pdd> vpdd;

//蟶ク逕ィ蟶ク驥?int逧?怙螟ァ蛟シ;lli逧?怙螟ァ蛟シ;db逧?ッッ蟾ョ逶ク蜈ウ蟶ク謨ー;谺ァ諡牙クク謨ー;蝨?捉邇?遘サ蜉ィ蜷鷹?;蜿匁ィ。菴ソ逕ィ逧?勁謨ー
int oo=(~0u)>>1;
lli ooll=(~0ull)>>1;
db inf=1e+10;
db eps=1e-10;
db gam=0.5772156649015328606;
db pi=acos(-1.0);
int dx[]={1,0,-1,0,1,-1,-1,1,0};
int dy[]={0,1,0,-1,1,1,-1,-1,0};
int MOD=1000000007;

//蟶ク逕ィ蜃ス謨ー:譛?、ァ譛?ー丞?譖エ譁ー;謨ー蟄ヲ逶ク蜈ウ蜃ス謨ー;霎灘?蜥瑚セ灘?;譬醍憾謨ー扈?蟷カ譟・髮?蜿ッ蜷亥ケカ蝣?
template<typename type>inline bool cmax(type& a,const type& b){rtn a<b?a=b,true:false;}
template<typename type>inline bool cmin(type& a,const type& b){rtn b<a?a=b,true:false;}
template<typename type>inline type sqr(const type& x){rtn x*x;}
template<typename type>inline type mod(const type& x){rtn x%MOD;}
inline int sgn(const db& x){rtn (x>+eps)-(x<-eps);}
inline int dbcmp(const db& a,const db& b){rtn sgn(a-b);}
template<typename type>inline pr<type,type> operator-(const pr<type,type>& x){rtn mp(-x.x,-x.y);}
template<typename type>inline pr<type,type> operator+(const pr<type,type>& a,const pr<type,type>& b){rtn mp(a.x+b.x,a.y+b.y);}
template<typename type>inline pr<type,type> operator-(const pr<type,type>& a,const pr<type,type>& b){rtn mp(a.x-b.x,a.y-b.y);}
template<typename type>inline pr<type,type> operator*(const pr<type,type>& a,const type& b){rtn mp(a.x*b,a.y*b);}
template<typename type>inline pr<type,type> operator/(const pr<type,type>& a,const type& b){rtn mp(a.x/b,a.y/b);}
template<typename type>inline pr<type,type>& operator-=(pr<type,type>& a,const pr<type,type>& b){rtn a=a-b;}
template<typename type>inline pr<type,type>& operator+=(pr<type,type>& a,const pr<type,type>& b){rtn a=a+b;}
template<typename type>inline pr<type,type>& operator*=(pr<type,type>& a,const type& b){rtn a=a*b;}
template<typename type>inline pr<type,type>& operator/=(pr<type,type>& a,const type& b){rtn a=a/b;}
template<typename type>inline type cross(const pr<type,type>& a,const pr<type,type>& b){rtn a.x*b.y-a.y*b.x;}
template<typename type>inline type dot(const pr<type,type>& a,const pr<type,type>& b){rtn a.x*b.x+a.y*b.y;}
template<typename type>inline type gcd(type a,type b){if(b)whl((a%=b)&&(b%=a));rtn a+b;}
template<typename type>inline type lcm(type a,type b){rtn a*b/gcd(a,b);}
template<typename istream,typename first_type,typename second_type>inline istream& operator>>(istream& cin,pr<first_type,second_type>& x){rtn cin>>x.x>>x.y;}
template<typename ostream,typename first_type,typename second_type>inline ostream& operator<<(ostream& cout,const pr<first_type,second_type>& x){rtn cout<<x.x<<" "<<x.y;}
template<typename istream,typename type>inline istream& operator>>(istream& cin,vec<type>& x){rep(i,sz(x))cin>>x[i];rtn cin;}
template<typename ostream,typename type>inline ostream& operator<<(ostream& cout,const vec<type>& x){rep(i,sz(x))cout<<x[i]<<(i+1==sz(x)?"":" ");rtn cout;}
inline ostream& pdb(int prcs,db x){rtn cout<<setprecision(prcs)<<fixed<<(sgn(x)?(x):0);}
template<typename type>inline void bit_inc(vec<type>& st,int x,type inc){whl(x<sz(st))st[x]+=inc,x|=x+1;}
template<typename type>inline type bit_sum(const vec<type>& st,int x){type s=0;whl(x>=0)s+=st[x],x=(x&(x+1))-1;rtn s;}
template<typename type>inline type bit_kth(const vec<type>& st,int k){int x=0,y=0,z=0;whl((1<<(++y))<=sz(st));fdt(i,y-1,0){if((x+=1<<i)>sz(st)||z+st[x-1]>k)x-=1<<i;else z+=st[x-1];}rtn x;}
inline void make_set(vi& st){rep(i,sz(st))st[i]=i;}
inline int find_set(vi& st,int x){int y=x,z;whl(y!=st[y])y=st[y];whl(x!=st[x])z=st[x],st[x]=y,x=z;rtn y;}
inline bool union_set(vi& st,int a,int b){a=find_set(st,a),b=find_set(st,b);rtn a!=b?st[a]=b,true:false;}
template<typename type>inline void merge(type& a,type& b){if(sz(a)<sz(b))swap(a,b);whl(sz(b))a.ins(*b.begin()),b.ers(b.begin());}

//蛻晏ァ句喧
struct Initializer
{
#ifndef DEBUG
	Initializer(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#else
	~Initializer(){runtime();}
#endif
}initializer;

//髱樊?蜃?#define feach(e,s) for (__typeof__((s).begin()) e=(s).begin();e!=(s).end();++e)
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
using __gnu_cxx::rope;
template<typename key,typename value>class ext_map:public __gnu_pbds::tree<key,value,less<key>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>{};
#define ctz __builtin_ctz
#define clz __builtin_clz
#define bc __builtin_popcount

int main()
{
	int n,q;
	whl(cin>>n>>q,n||q)
	{
		map<str,int> beg;
		map<str,int> end;
		rep(i,n)
		{
			str a;
			int b,c;
			cin>>a>>b>>c;
			beg[a]=c-b+1;
			cmax(end[a],c);
		}
		vec<pr<pii,str> > rec;
		feach(it,beg) rec.pb(mp(mp(it->y,end[it->x]),it->x));
		rep(i,q)
		{
			int qry;
			cin>>qry;
			bool fnd=false;
			rep(i,sz(rec)) if (rec[i].x.x<=qry&&qry<=rec[i].x.y)
			{
				cout<<rec[i].y<<" "<<qry-rec[i].x.x+1<<endl;
				fnd=true;
			}
			if (!fnd) cout<<"Unknow"<<endl;
		}
	}
}

Compiler output:
a.cc:80:2: error: #else without #if
   80 | #else
      |  ^~~~
a.cc:81:9: warning: "prt" redefined
   81 | #define prt(x) cerr<<"隨ャ"<<__LINE__<<"陦圭t: "<<#x"\t="<<(x)<<endl
      |         ^~~
a.cc:71:9: note: this is the location of the previous definition
   71 | #define prt(x) (cerr)
      |         ^~~
a.cc:82:9: warning: "asrtWA" redefined
   82 | #define asrtWA(s) do if(!(s))cerr<<"assert("#s")"<<endl;whl(0)
      |         ^~~~~~
a.cc:72:9: note: this is the location of the previous definition
   72 | #define asrtWA(s) do if(!(s))exit(0);whl(0)
      |         ^~~~~~
a.cc:83:9: warning: "asrtTLE" redefined
   83 | #define asrtTLE(s) do if(!(s))cerr<<"assert("#s")"<<endl;whl(0)
      |         ^~~~~~~
a.cc:73:9: note: this is the location of the previous definition
   73 | #define asrtTLE(s) do if(!(s))whl(1);whl(0)
      |         ^~~~~~~
a.cc:84:9: warning: "asrtMLE" redefined
   84 | #define asrtMLE(s) do if(!(s))cerr<<"assert("#s")"<<endl;whl(0)
      |         ^~~~~~~
a.cc:74:9: note: this is the location of the previous definition
   74 | #define asrtMLE(s) do if(!(s))whl(new int);whl(0)
      |         ^~~~~~~
a.cc:85:9: warning: "asrtOLE" redefined
   85 | #define asrtOLE(s) do if(!(s))cerr<<"assert("#s")"<<endl;whl(0)
      |         ^~~~~~~
a.cc:75:9: note: this is the location of the previous definition
   75 | #define asrtOLE(s) do if(!(s))whl(1)puts("OLE");whl(0)
      |         ^~~~~~~
a.cc:86:9: warning: "asrtRE" redefined
   86 | #define asrtRE(s) do if(!(s))cerr<<"assert("#s")"<<endl;whl(0)
      |         ^~~~~~
a.cc:76:9: note: this is the location of the previous definition
   76 | #define asrtRE(s) do if(!(s))*(int*)0=0;whl(0)
      |         ^~~~~~
a.cc:87:9: warning: "runtime" redefined
   87 | #define runtime() cerr<<"Used: "<<db(clock())/CLOCKS_PER_SEC<<"s"<<endl
      |         ^~~~~~~
a.cc:77:9: note: this is the location of the previous definition
   77 | #define runtime() (cerr)
      |         ^~~~~~~
a.cc:88:9: warning: "input" redefined
   88 | #define input(in)
      |         ^~~~~
a.cc:78:9: note: this is the location of the previous definition
   78 | #define input(in) freopen(in,"r",stdin)
      |         ^~~~~
a.cc:89:9: warning: "output" redefined
   89 | #define output(out)
      |         ^~~~~~
a.cc:79:9: note: this is the location of the previous definition
   79 | #define output(out) freopen(out,"w",stdout)
      |         ^~~~~~
a.cc:90:2: error: #endif without #if
   90 | #endif
      |  ^~~~~
a.cc:102:12: error: 'lli' was not declared in this scope
  102 | typedef pr<lli,lli> pll;
      |            ^~~
a.cc:102:16: error: 'lli' was not declared in this scope
  102 | typedef pr<lli,lli> pll;
      |                ^~~
a.cc:102:19: error: template argument 1 is invalid
  102 | typedef pr<lli,lli> pll;
      |                   ^
a.cc:102:19: error: template argument 2 is invalid
a.cc:115:1: error: 'lli' does not name a type
  115 | lli ooll=(~0ull)>>1;
      | ^~~
a.cc: In function 'int main()':
a.cc:194:23: error: 'it' was not declared in this scope; did you mean 'int'?
  194 |                 feach(it,beg) rec.pb(mp(mp(it->y,end[it->x]),it->x));
      |                       ^~
      |                       int
a.cc:194:17: error: 'feach' was not declared in this scope
  194 |                 feach(it,beg) rec.pb(mp(mp(it->y,end[it->x]),it->x));
      |                 ^~~~~