Order two strings

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

Problem information

Author: Guillem Godoy

Generation: 2026-01-25T14:26:50.475Z

© Jutge.org, 2006–2026.
https://jutge.org