P29463 [洛谷] [COCI2015-2016#5] ZAMKA
普及-
题目描述

Problem Description

Given three integers \( L, D, X \), you need to find two integers \( N, M \) such that:

  • \( N \) is the smallest integer that satisfies \( L \le N \le D \) and the sum of its digits is \( X \);
  • \( M \) is the largest integer that satisfies \( L \le M \le D \) and the sum of its digits is \( X \).

It is guaranteed that \( N \) and \( M \) always exist.

Input Format

The input consists of three lines.

  • The first line contains an integer \( L \).
  • The second line contains an integer \( D \).
  • The third line contains an integer \( X \).

Output Format

The output consists of two lines.

  • The first line contains an integer \( N \).
  • The second line contains an integer \( M \).

Sample Input and Output

Sample Input #1

1
100
4

Sample Output #1

4
40

Sample Input #2

100
500
12

Sample Output #2

129
480

Sample Input #3

1
10000
1

Sample Output #3

1
10000

Notes

Data Size and Constraints

For 100% of the data, \( 1 \le L \le D \le 10^4 \) and \( 1 \le X \le 36 \).

Notes

This problem is translated from COCI2015-2016 CONTEST #5 T1 ZAMKA.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 100 4
样例输出
4 40