#include<map>
#include<utility>
using namespace std;
map<string,string>ma;
pair<string,string>p;
int main()
{
int m, n, a;
string s,t,str;
cin>>n>>m;
while(n--)
{
cin>>s>>t;
p.first = s;
p.second = t;
ma.insert(p);
}
while(m--)
{
cin>>a>>str;
if(a==1)
{
if(ma.find(str)!=ma.end())
{
cout<<ma[str];
}
else{
cout<<"NO";
}
}
if(a==2)
{
if(str<=(ma.begin()->first))
{
cout<<"NO";
}
else
{
auto it = ma.lower_bound(str);
it--;
cout<<it->second;
}
}
if(a==3)
{
if(str>=((--ma.end())->first))
{
cout<<"NO";
}
else
{
auto it = ma.upper_bound(str);
cout<<it->second;
}
}
cout<<endl;
}
}
0 回复
0 转发
2 喜欢
3 阅读



