//* Problem  : 2229 - Spell checker
//* Contest  : acm.tju.edu.cn
//* Type     : Solution
//* Date     : 2007.08.21
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

struct ttword{
	int len;
	char s[16];
	int id;
} a[10001];

int n, w[10001];
char s[100];
int iindex[20];

int cmp(const void *a, const void *b)
{
	ttword * aa = (ttword*)a, *bb = (ttword*)b;
	return aa->len - bb->len;
}

int cmp_l(char *sshort, char *slong)
{
	int is, il;
	is = il = 0;
	while (sshort[is] && sshort[is] == slong[il])
	{
		is++;
		il++;
	}
	il++;
	while (sshort[is] && sshort[is] == slong[il])
	{
		is++;
		il++;
	}
	if (!sshort[is] && !slong[il]) return 1;
	return 0;
}

int cmp_e(char *s1, char *s2)
{
	int res, i;
	for (i = res = 0; s1[i]; i++)
		if (s1[i] != s2[i]) res++;
	return res;
}

int check()
{
	memset(w, 0, sizeof(w));
	int i, k, len = strlen(s);
	for (i = iindex[len]; a[i].len == len; i++)
	{
		k = cmp_e(a[i].s, s);
		if (!k) return 1;
			else if (k == 1) w[a[i].id] = i;
	}
	for (i = iindex[len-1]; a[i].len == len-1; i++)
	{
		k = cmp_l(a[i].s, s);
		if (k) w[a[i].id] = i;
	}
	for (i = iindex[len+1]; a[i].len == len+1; i++)
	{
		k = cmp_l(s, a[i].s);
		if (k) w[a[i].id] = i;
	}
	return 0;
}

int main()
{
	int k, i; n = 0;
	while (scanf("%s", s) && s[0] != '#')
	{
		n++;
		a[n].len = strlen(s);
		a[n].id = n;
		strcpy(a[n].s, s);
	}
	//
	qsort(a, n+1, sizeof(a[0]), cmp);
	for (i = 0; i < 17; i++) iindex[i] = 1;
	for (i = 1; i <= n; i++)
		if (a[i].len != a[i-1].len)
			iindex[a[i].len] = i;
	//
	while (scanf("%s", s) && s[0] != '#')
	{
		if (check()) printf("%s is correct\n", s);
			else
			{
				printf("%s:", s);
				for (i = 1; i <= n; i++)
					if (w[i])
						printf(" %s", a[w[i]].s);
				printf("\n");
			}
	}
	return 0;
}
