cho.sh
Notes
Loading...

Dramatic Multiplication

Time limit

2s

Memory limit

128 MB

Problem

For a positive integer X, let R(X) be the number obtained by moving the last decimal digit of X to the front. For example, if X = 102564, then R(X) = 410256.

A positive integer X is called n-dramatic if n × X = R(X).

Given n and k, find the smallest n-dramatic number whose last digit is k. If no such number exists, print 0. The decimal representation of the number cannot start with 0.

Input

The first line contains n and k separated by a space.

1 ≤ n ≤ 9, 1 ≤ k ≤ 9

Output

Print the smallest n-dramatic number whose last digit is k. If no such number exists, print 0.