Hide

Problem C
The Noble Houses of Apaxia

The Oriental Institute has made yet another exciting discovery about the ancient (and certainly not fictitious) Apaxian civilization: when an Apaxian performed a noble deed, they were granted a noble name. Their noble name was obtained via a simple transformation of their regular name. For example, suppose there was an Apaxian with the following name:

menolaxios mox

Their noble name is obtained simply by changing their last name: it will now be repeated as many times as the length (in characters) of the last name. So, the noble name of the above Apaxian becomes:

menolaxios moxmoxmox

There was, however, an exception: Apaxians considered the number five to be very unlucky, so last names with five characters were repeated four times instead. So, the last name maxos would become maxosmaxosmaxosmaxos instead of maxosmaxosmaxosmaxosmaxos.

The Oriental Institute has, once again, asked us to apply our prodigious string processing skills to help them compute the noble names of several Apaxians.

Input

The input contains two strings separated by a single space: a first name and a last name. Each string contains only lowercase letters, and is at least 2 characters long and at most 10 characters long.

Output

Given the full name in the input, you must produce the noble name according to the rules described above. You must include both the first name (which is not changed) and the last name (which does change), separated by a single space.

Sample Input 1 Sample Output 1
menolaxios mox
menolaxios moxmoxmox
Sample Input 2 Sample Output 2
alemax maxos
alemax maxosmaxosmaxosmaxos

Please log in to submit a solution to this problem

Log in