#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <ctype.h>
using namespace std;
set<string> list;
multimap<string, string> ans;
int main()
{
string s;
string line;
list.clear();
ans.clear();
while(getline(cin,s))
{
if(s == "::")
break;
for( int i = 0; s[i] != '\0'; i++)
s[i] = tolower(s[i]);
list.insert(s);
}
while(getline(cin,line))
{
for( int i = 0; i<line.size(); i++)
line[i] = tolower(line[i]);
for( int i = 0; i < line.size(); i++)
{
if(!isalpha(line[i]))
continue;
string str;
int j = i;
while(isalpha(line[j]))
{
str += line[j];
j++;
}
if(!list.count(str))
{
for( int k =0; str[k] != '\0'; k++)
str[k] = toupper(str[k]);
string str3 = line;
str3.replace(i, str.size(), str);
ans.insert(make_pair(str, str3));
}
i = j;
}
}
map<string,string> :: iterator it = ans.begin();
for( ; it != ans.end(); it++)
cout<<it->second<<endl;
return 0;
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <ctype.h>
using namespace std;
set<string> list;
multimap<string, string> ans;
int main()
{
string s;
string line;
list.clear();
ans.clear();
while(getline(cin,s))
{
if(s == "::")
break;
for( int i = 0; s[i] != '\0'; i++)
s[i] = tolower(s[i]);
list.insert(s);
}
while(getline(cin,line))
{
for( int i = 0; i<line.size(); i++)
line[i] = tolower(line[i]);
for( int i = 0; i < line.size(); i++)
{
if(!isalpha(line[i]))
continue;
string str;
int j = i;
while(isalpha(line[j]))
{
str += line[j];
j++;
}
if(!list.count(str))
{
for( int k =0; str[k] != '\0'; k++)
str[k] = toupper(str[k]);
string str3 = line;
str3.replace(i, str.size(), str);
ans.insert(make_pair(str, str3));
}
i = j;
}
}
map<string,string> :: iterator it = ans.begin();
for( ; it != ans.end(); it++)
cout<<it->second<<endl;
return 0;
}