Contest Duration: - (local time) (120 minutes) Back to Home
A - Repdigit Number /

Time Limit: 2 sec / Memory Limit: 1024 MB

### 問題文

• X10^N 未満の正整数で，X10 進法表記したときのどの桁の数字も同じである．
• XM の倍数である．

ただし，条件を満たす正整数 X が存在しない場合には -1 と出力してください．

### 制約

• 1\leq N\leq 10^5
• 1\leq M\leq 10^9

### 入力

N M


### 入力例 1

7 12


### 出力例 1

888888


### 入力例 2

9 12


### 出力例 2

888888888


### 入力例 3

1 3


### 出力例 3

9


### 入力例 4

1000 25


### 出力例 4

-1


### 入力例 5

30 1


### 出力例 5

999999999999999999999999999999


Score : 300 points

### Problem Statement

You are given positive integers N and M. Find the maximum positive integer X that satisfies all of the following conditions.

• X is a positive integer less than 10^N, and all digits in the decimal representation of X are the same.
• X is a multiple of M.

If no positive integer X satisfies the conditions, print -1.

### Constraints

• 1\leq N\leq 10^5
• 1\leq M\leq 10^9

### Input

The input is given from Standard Input in the following format:

N M


### Output

Print the maximum positive integer X that satisfies all of the conditions, or -1 if no such positive integer X exists.

### Sample Input 1

7 12


### Sample Output 1

888888


Four positive integers X satisfy the conditions: 444, 888, 444444, 888888. The answer is the maximum of them, which is 888888.

### Sample Input 2

9 12


### Sample Output 2

888888888


Six positive integers X satisfy the conditions: 444, 888, 444444, 888888, 444444444, 888888888.

### Sample Input 3

1 3


### Sample Output 3

9


Three positive integers X satisfy the conditions: 3, 6, 9.

### Sample Input 4

1000 25


### Sample Output 4

-1


No positive integers X satisfy the conditions.

### Sample Input 5

30 1


### Sample Output 5

999999999999999999999999999999