In MS-DOS there exists a `rename' command that allows you to change the name of a file. There is an equivalent command in Unix called `mv'. Both commands take arguments in the same way:

rename oldname newname
mv oldname newname

However, the two commands treat the wild-card character `*' quite differently. In MS-DOS, you can say:

rename old* new*

and you will find that any filenames you have that previously began with the three characters `old' have those characters replaces by `new'. Try the equivalent under Unix and you will probably get an error message :-( `mv' will only take the simple two argument, no wild-card form.

To rectify this discrepancy, your program must convert a `rename' command in to a series of `mv's'.


Each dataset starts with a list of filenames. These appear one per line. The list is terminated by a line containing the word `end'. Following the list of filenames is the sequence of `rename' commands. Each command appears on one line in the form:

rename wildfrom wildto

from and to will both contain one wild-card character, `*'. After the last `rename' command will be a line containing only the word `end'. There won't be two files with the same name.


For each rename command in the input, you program should first echo the rename command itself, in the same form as the input:

rename wildfrom wildto

Following that, your program should output the set of `mv' commands needed to perform the equivalent renaming. Each `mv' should appear on its own line in the form:

mv from to

The order of the mv-commands in the output should be the order of the filenames in the input. Print a blank line after each dataset.

Notes: The real MS-DOS `*' has some odd properties which do not concern us here. For example, an MS-DOS `*' will match at most eight characters, none of which is a period `.'. No such restrictions apply to our idealised `*' which will match any number of any printable character. MS-DOS treats upper and lower case letters the same. Unix treats the two cases as distinct, as should your program. MS-DOS limits filenames to 12 characters, including a `.' fixed at the 9th position. Some versions of Unix limit filenames to 14 characters. This is the limit your program should assume. Each `rename' command should be performed on the original list of filenames, not on the results of the previous command.

Sample Input

rename abFile*.c bprog*.cxx
rename ac*.c ib*.cpp

Sample Output

rename abFile*.c bprog*.cxx
mv abFile001.c bprog001.cxx
mv abFile.c bprog.cxx
mv abFileprog.c bprogprog.cxx

rename ac*.c ib*.cpp
mv acm.c ibm.cpp