#arc149a. [arc149_a]Repdigit Number
[arc149_a]Repdigit Number
Problem Statement
You are given positive integers and . Find the maximum positive integer that satisfies all of the following conditions.
- is a positive integer less than , and all digits in the decimal representation of are the same.
- is a multiple of .
If no positive integer satisfies the conditions, print -1
.
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the maximum positive integer that satisfies all of the conditions, or -1
if no such positive integer exists.
Sample Input 1
7 12
Sample Output 1
888888
Four positive integers satisfy the conditions: . The answer is the maximum of them, which is .
Sample Input 2
9 12
Sample Output 2
888888888
Six positive integers satisfy the conditions: .
Sample Input 3
1 3
Sample Output 3
9
Three positive integers satisfy the conditions: .
Sample Input 4
1000 25
Sample Output 4
-1
No positive integers satisfy the conditions.
Sample Input 5
30 1
Sample Output 5
999999999999999999999999999999