Wildcard (Large)

Given two filenames A and B, find the shortest star pattern that matches A but not B, breaking ties by fewer stars then lexicographic order.

Hard8Dynamic programmingString matchingBFSNo attempts yetTime limit5sMemory limit512 MB

Problem

Many operating systems let you use * (an asterisk) as a wildcard when you name a file. A * matches any string, and the empty string counts.

Wildcards are often used to name several files at once, and they also make naming a single file easier. Suppose you want to name the file pascalisamazing. If it is the only file matching the pattern pascal*, then that pattern names pascalisamazing, and pascal* is much shorter to type.

Given two file names, find the shortest pattern that matches the first name but not the second.

A pattern is a string of lowercase letters and *. The pattern matches a name if you can replace each * in it with some string, possibly the empty string, and get exactly that name.

Input

The first line has the number of test cases TT. Each test case takes two lines: the first file name AA on one line and the second file name BB on the next. File names consist of lowercase letters only.

Constraints

  • 1T1001 \le T \le 100
  • AA and BB are different strings
  • AA and BB are each 1 to 50 characters long

Output

For each test case print one line in this format.

Case #X: Y

XX is the test case number and YY is the shortest pattern that matches AA but not BB. If several patterns share the shortest length, print the one with the fewest asterisks. If several still remain, print the smallest one in lexicographic order. Compare characters by their ASCII codes, where the code 42 of * is smaller than any lowercase letter.