#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<iostream>
#include<string>
#include<map>
using namespace std;
const int maxn = 100;
int n,x,m;
map<string,string>stl;
struct node
{
int l,r;
} c[maxn];
int main()
{
string a,b;
scanf("%d %d",&n,&m);
for(int i=0; i<m; i++)
{
cin>>a>>b;
if(a.length()<b.length())
{
stl[a]=a;
stl[b]=a;
}
else if(a.length()>b.length())
{
stl[a]=b;
stl[b]=b;
}
else
{
stl[a]=a;
stl[b]=a;
}
}
string c;
for(int i=0; i<n; i++)
{
cin>>c;
if(i==0)
cout<<stl[c];
else cout<<" "<<stl[c];
}
cout<<endl;
return 0;
}
codeforce499B - Lecture
最新推荐文章于 2018-05-24 17:02:08 发布