#P11568. Palindromic Product Construction

    ID: 13659 Type: Default 1000ms 256MiB

Palindromic Product Construction

Palindromic Product Construction

Given two positive integers (n) and (m), you are required to construct two positive integers (x) and (y) (without leading zeros) such that (x) has exactly (n) digits, (y) has exactly (m) digits, and the product (x \times y) is a palindrome. A number is said to be a palindrome if it reads the same backward as forward.

One simple construction is to use repunit numbers. A repunit is a number consisting only of the digit 1. If you choose (x = \underbrace{11\ldots1}{n}) and (y = \underbrace{11\ldots1}{m}), then their product (x \times y) is guaranteed to be a palindrome.

Note: The answer you output must satisfy the conditions for any given input.

inputFormat

The input consists of a single line with two space-separated positive integers (n) and (m), representing the number of digits of (x) and (y) respectively.

outputFormat

Output two space-separated integers (x) and (y) such that (x) is an (n)-digit number, (y) is an (m)-digit number, and (x \times y) is a palindrome. It is guaranteed that such a solution always exists. In our construction, we use repunit numbers which consist solely of the digit 1.

sample

1 1
1 1