Minimum Integer sequence

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 3522
64-bit integer IO format: %I64d      Java class name: Main

Description

Now we have two integers A and B, after insert B into A, we can get a new integer C, and then the problem comes: how to get a smallest C? For example, let A = 345, B = 478. As there are there digits in A, so there are four places for B to insert into. We can get 478345, 347845, 344785, 345478.After comparing, we could know that the smallest C is 344785.

Input

There are multiple test cases. Each test case takes one line, Each line contents two integers A and B(there will be less than 100000 digits in A and B and there is no digit values 0 in A and B), the two integers are separated by a space, process to the end of file.

Output

For each test case, output the smallest integer C.

Sample Input

345 478
12345 678
123 123

Sample Output

344785
12345678
112323

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .