#include <iostream>
#include <fstream>
#include <string>
#include <map>

using namespace std;


int main() {
	ifstream fin("dict.txt");

	map<string,string> dict;
	string line;
	while (getline(fin, line)) {
		size_t pos = line.find(',');
		if (pos == string::npos)
			continue;
		dict[line.substr(0,pos)]=string(line,pos+1);
	}
	for(auto i:dict){
		cout << i.first << " translates to " << i.second<< endl;
	}
	fin.close();
	
	fin.open("text.txt", ifstream::in);
	while(fin>>line)
	{
		decltype(dict.end()) p;
		if ((p = dict.find(line)) != dict.end()) {
			cout << p->second  << ' ';
		} else {
			cout << line << ' ';
		}
	}
	cout << endl;


	return 0;
}
