#pragma warning(disable : 4786) #include <iostream> #include <string> #include <map> using namespace std; #define MAX 0x7fffffff #define M typedef string String; map<String,String> Map; bool isChar(char ch) { if(ch >= 'a' && ch <= 'z') return true; return false; } void run() { String s1,s2; cin >> s1; while(cin >> s1) { if(s1 == "END") break; cin >> s2; Map[s2]=s1; } cin >> s1; getline(cin,s1); while(getline(cin,s1)) { s2 = ""; if(s1 == "END") break; for(int i=0;i<s1.size();i++) { if(isChar(s1[i])) { s2 += s1[i]; } else { if(Map[s2] != "") cout << Map[s2]; else cout << s2; cout << s1[i]; s2 = ""; } } cout << endl; } } int main(int argc, char *argv[]) { #ifdef __LOCAL freopen("in.txt","r",stdin); #endif run(); return 0; }