You have two strings,  and . Find a string, , such that:

  •  can be expressed as  where  is a non-empty substring of  and  is a non-empty substring of .
  •  is a palindromic string.
  • The length of  is as long as possible.

For each of the  pairs of strings ( and ) received as input, find and print string  on a new line. If you’re able to form more than one valid string , print whichever one comes first alphabetically. If there is no valid answer, print  instead.

solution