#d1307. 约分
约分
Fraction Reduction
Problem Source
https://codeforces.com/gym/103447/problem/D
Problem Description
Everyone knows what it means for two fractions to be equivalent: we say and are equivalent if and only if .
Usually, reducing a fraction means dividing both numerator and denominator by a common factor. But that is too hard, so little t proposes a new definition of reduction: we may simultaneously strike out several identical digits from the numerator and denominator at once. For example, can become by striking out one digit, or ; it is easy to see that this may make the original fraction no longer equivalent to the current one.
Now little t asks you: under this reduction operation, what is the simplest fraction of ? A simplest fraction is, among all equivalent to , the one with the smallest . For example:
- $\frac{163}{326} \rightarrow \frac{16}{26} \rightarrow \frac{1}{2}$, we say is the simplest fraction of .
- The simplest fraction of is , because .
- The simplest fraction of is , because is invalid.
Note that if the answer is , you should output . You can think of leading zeros as automatically vanishing during reduction.
Input Format
One line with two integers , the numerator and denominator respectively.
Output Format
One line with two integers , the numerator and denominator of the simplest fraction respectively.
Sample Input
2232 162936
Sample Output
232 16936
Constraints
For all data, .