Order two strings X23111


Statement
 

pdf   zip

Given two strings, we want to write them in lexicographic order.

Note: Recall that the comparison operator << in C++ is defined for strings as the lexicographic order, that is, the expression s<ts<t evaluates to true if ss is lexicographically smaller than tt.

Note: It is not allowed to use functions, vectors and any other way to store massive data (although you can read the input as strings, but not to access to their positions). The solution must deal with the input data sequentially without storing arbitrarily large intermediate memory.

Input

The input has several cases, each one described in one line. For each case, we have two strings ss and tt.

Output

For each case, you have to write the smallest of ss and tt, followed by a blank space, followed by the biggest of ss and tt, in one line.

Observation

Public test cases
  • Input

    hello bye
    bye hello
    a a
    aaa aba
    aba aaa
    aaa aab
    aab aaa
    abb ba
    ba abb

    Output

    bye hello
    bye hello
    a a
    aaa aba
    aaa aba
    aaa aab
    aaa aab
    abb ba
    abb ba
    
  • Information
    Author
    Guillem Godoy
    Language
    English
    Official solutions
    Unknown.
    User solutions
    C++ Python