This page is still under construction.

Parts of this page are still being built. What you see may change.

Math is a Physical Education Subject 3

Interview

Time limit1sMemory limit1024 MB

Summary
Given the concatenation of all integers from A to B, recover A and B, choosing the smallest A if several pairs fit.
Level

Medium4 of 10

Topics
String, Brute force, Implementation, Math
Solved
No attempts yet

Problem

Ihwan is a genius five-year-old baby living in the era of the Fourth Industrial Revolution. One day, after discovering Ihwan's genius, his kindergarten teacher gave him the following problem.

What is the sum of all integers from AA to BB, inclusive?

Ihwan is a genius, but he is still a baby and does not really know what addition is. The next day, Ihwan wrote all the integers from AA to BB, inclusive, in increasing order with no spaces in his notebook. For example, when A=4A = 4 and B=21B = 21, the answer Ihwan wrote down is 456789101112131415161718192021.

Ihwan is a genius with exceptional obsession over assignments, but his teacher is not. In fact, Ihwan's teacher even forgot what the two numbers he called yesterday were. The only information the teacher remembers is that both AA and BB were integers between 11 and 999999, inclusive, and that naturally AA was less than or equal to BB.

Given the sequence of digits Ihwan wrote down, can you find the two numbers the teacher called?

Input

The first line gives the string SS representing the answer Ihwan wrote down. SS consists only of digits (0123456789), and its length is between 11 and 2 8892\ 889, inclusive.

Output

Print the two integers AA and BB that Ihwan's teacher called, separated by a space. If more than one answer is possible, print the one with the smallest AA.

Because Ihwan always writes the correct answer, only inputs for which an answer satisfying the problem's conditions exists are given.

Examples4

  1. Example 1

    Input
    9101112
    
    Expected output
    9 12
    
  2. Example 2

    Input
    12
    
    Expected output
    1 2
    
  3. Example 3

    Input
    999
    
    Expected output
    999 999
    
  4. Example 4

    Input
    456789101112131415161718192021
    
    Expected output
    4 21