Olympic Winning Ticket
After the Olympics ended and his attempt to win the Olympic lottery failed, Vasya discovered the reason behind his loss. It appears that the English, as true heirs of the legendary Agent 007, had discreetly given him incorrect information.
To have a chance at winning the lottery, Vasya needed to ask two random holders of Olympic lottery tickets for their numbers, labeled as A and B. Assuming neither number has leading zeros, Vasya's task was to find a position to insert the number B into the number A such that the resulting number is the smallest possible. The ticket with this newly formed number would be the winning one, and how Vasya retrieves it is another matter...
For instance, if Vasya was told that A = 246 and B = 489, he could insert B into four different positions, resulting in these possible ticket numbers: 489246, 248946, 244896, and 246489. Clearly, the smallest number among these is 244896, which is the one Vasya should pursue.
Write a program to help Vasya quickly identify the numbers of his potential winning tickets.
Input
You will be given multiple test cases. Each test case is on a separate line and consists of two integers A and B, separated by a space. Each number can have up to 100000 digits, and neither A nor B contains leading zeros. The input continues until the end of the file.
Output
For each test case, output the ticket number that Vasya should look for on a separate line.