#include<bits/stdc++.h>
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
#define newl cout<<"\n"
#define putcase cout<<"Case "<<++cse<<":"
#define putcase2 cout<<"Case #"<<++cse<<":"
using namespace std;
int main()
{
vector<string>vs1;
vector<string>vs2;
int m , n;
string a , b;
cin>>n>>m;
string mn[n];
ff(i,0,m){
string a , b;
cin>>a>>b;
vs1.push_back(a);
vs2.push_back(b);
}
ff(i,0,n){
cin>>mn[i];
}
ff(i,0,n){
ff(j,0,m){
if(mn[i]==vs1[j]){
if(vs1[j].size()>vs2[j].size())
cout<<vs2[j];
else
cout<<vs1[j];
if(i!=n-1)
cout<<" ";
break;
}
}
}
return 0;
}
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
#define newl cout<<"\n"
#define putcase cout<<"Case "<<++cse<<":"
#define putcase2 cout<<"Case #"<<++cse<<":"
using namespace std;
int main()
{
vector<string>vs1;
vector<string>vs2;
int m , n;
string a , b;
cin>>n>>m;
string mn[n];
ff(i,0,m){
string a , b;
cin>>a>>b;
vs1.push_back(a);
vs2.push_back(b);
}
ff(i,0,n){
cin>>mn[i];
}
ff(i,0,n){
ff(j,0,m){
if(mn[i]==vs1[j]){
if(vs1[j].size()>vs2[j].size())
cout<<vs2[j];
else
cout<<vs1[j];
if(i!=n-1)
cout<<" ";
break;
}
}
}
return 0;
}
No comments:
Post a Comment