Search the Khoj

Jalil is a five year old wonder boy. He has a very strange memory power. He can memorize any number in his brain with at most one digit error. If you ask him to tell first 1000 digits of PI (3.141592...), he will go through it without any hesitation. But he could have made a mistake in at most one digit, whether you ask him to tell first 100 digits or 5 digits. Suppose you asked him to tell first 4 digits of PI after decimal place. Probable answer from him could be 1415, 1416, 0415, 1475 etc. but not 0516, 1517 etc. Due to ACM ICPC Preliminary contest, today is a school holiday for Jalil but not for his mommy. He is feeling bored and thought about calling mommy to come home early. But his mommy has a new mobile phone with new number. Though his mommy told him the number but he is afraid he might have forgotten one of the digits of the mobile number. He took his dad’s mobile and searched for his mommy’s number in the contact list, but could not succeed. Jalil is cent percent sure that one of the numbers in the contact list of his dad’s mobile is his mommy’s number. So he took a backup of his dad’s contact list in his computer and started matching the number he can remember with all the numbers in the contact list. As Jalil know that he might have mistaken at most one digit in his mommy’s mobile number, he is preparing a list of mobile numbers from his dad’s contact list such that each of the numbers is only at most one digit different from the number he remembers. As Jalil does not know programming, help him to prepare the list. Input First line of the input contain a positive integer T (T ≤ 10), the number of test cases. First line of each test case contains a positive integer number N (≤ 1000), number of mobile number in the dad’s contact list. Each of the next N lines will contain a mobile number from dad’s contact list. Next line will contain mommy’s phone number which Jalil can recall. A mobile number is a non-empty string of numeric characters (‘0’ to ‘9’, leading zero allowed) of length at most 11. Every mobile number (contact list and mommy’s number) given in a single test case will be of same length. Note that, ‘0123’ and ‘00123’ are different mobile numbers. Output For each test case, print the test case number in a single line followed by the list of probable number of mommy. Print the phone numbers according to the order in the input. Sample Input 2 3 0123456 0012345 0123457 0123458 2 123 124 123

2/2 Sample Output Case 1: 0123456 0123457 Case 2: 123 124