#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
bool compSameLen(char* first, char* second)
{
char* pCur = first;
int cnt = 0;
while (*pCur)
{
char* ret = strchr(second, *pCur);
if (ret)
{
cnt++;
}
pCur++;
}
if (cnt == strlen(first) - 1)
{
return true;
}
return false;
}
bool compLessLen(char* buf, char* dictStr)
{
char* pCur = buf;
int cnt = 0;
while (*pCur)
{
char* ret = strchr(dictStr, *pCur);
if (ret)
{
cnt++;
}
pCur++;
}
if (cnt == strlen(buf))
{
return true;
}
return false;
}
bool compMoreLen(char* buf, char* dictStr)
{
char* pCur = dictStr;
int cnt = 0;
while (*pCur)
{
char* ret = strchr(buf, *pCur);
if (ret)
{
cnt++;
}
pCur++;
}
if (cnt == strlen(dictStr))
{
return true;
}
return false;
}
int main()
{
vector<string> dict;
char buf[32];
while (true)
{
gets_s(buf);
if (strcmp(buf, "#") == 0)
{
break;
}
dict.push_back(buf);
}
while (true)
{
gets_s(buf);
if (strcmp(buf, "#") == 0)
{
break;
}
char dictStr[32];
vector<string> replaceStrs;
for (int i = 0; i < dict.size(); i++)
{
strcpy_s(dictStr, dict[i].c_str());
if (strcmp(buf, dictStr) == 0)
{
printf("%s is correct\n",buf);
goto GH;
}
int curLen = strlen(buf);
int dictLen = strlen(dictStr);
if (curLen == dictLen)
{
bool ret = compSameLen(buf,dictStr);
if (ret)
{
replaceStrs.push_back(dictStr);
}
}
else if (curLen == dictLen - 1)
{
bool ret = compLessLen(buf,dictStr);
if (ret)
{
replaceStrs.push_back(dictStr);
}
}
else if (curLen == dictLen + 1)
{
bool ret = compMoreLen(buf,dictStr);
if (ret)
{
replaceStrs.push_back(dictStr);
}
}
}
if (replaceStrs.empty())
{
printf("%s:", buf);
}
else
{
char output[256];
sprintf_s(output, "%s:", buf);
for (int k = 0; k < replaceStrs.size(); k++)
{
strcat_s(output, " ");
strcat_s(output, replaceStrs[k].c_str());
}
printf("%s", output);
}
GH:continue;
}
}