#include <bits/stdc++.h>
using namespace std;
map<string,string> m;
int main()
{
int n,k;
string name,tel;
cin>>n>>k;
for(int i=0;i<n;i++)
{
cin>>name>>tel;
m[name]=tel;
}
while(k--)
{
int c;
string x;
cin>>c>>x;
if(c==1){
auto it = m.find(x);
if(it!=m.end()) cout<<it->second<<endl;
else cout<<"NO"<<endl;
}else if(c==2){
auto it = m.lower_bound(x);
if(it!=m.begin()){
--it;
cout<<it->second<<endl;
}else cout<<"NO"<<endl;
}else if(c==3){
auto it = m.upper_bound(x);
if(it!=m.end()){
cout<<it->second<<endl;
}else cout<<"NO"<<endl;
}
}
return 0;
}
0 回复
0 转发
0 喜欢
5 阅读



