Construct the smallest and largest decimal numbers with a fixed number of digits and a given digit sum.
You are given two integers and .
Your task is to construct:
If it is impossible to form any -digit number with digit sum , report that no answer exists.
A valid number must have exactly digits. For the smallest number, the first digit cannot be zero unless .
This is a classic constructive problem: you need to place digits carefully so that the total sum is correct while keeping one result as small as possible and the other as large as possible.
The input contains two integers and .
Print two numbers separated by a space:
If it is impossible, print -1 -1.
Example 1
Input
2 15
Output
69 96
Explanation
For two digits with sum 15, the smallest valid number is 69 and the largest is 96.
Example 2
Input
1 0
Output
0 0
Explanation
A single digit number may be zero.
Example 3
Input
2 1
Output
10 10
Explanation
The only valid two-digit number with digit sum 1 is 10.
Example 4
Input
3 28
Output
-1 -1
Explanation
The maximum possible digit sum for three digits is 27, so this is impossible.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.