This page is still under construction.

Parts of this page are still being built. What you see may change.

Unusual Number

Time limit2sMemory limit512 MB

Summary
Given digit count a and multiplier b, find the smallest a-digit number whose last digit moved to the front equals b times the number, or report Impossible.
Level

Medium6 of 10

Topics
Math, Number theory, Implementation, Brute force
Solved
No attempts yet

Problem

A positive integer NN is an unusual number when it satisfies both of the conditions below.

  • NN has aa digits and its leading digit is not 0.
  • Let N′N' be the number formed by moving the last digit of NN to the front. Then N′=b×NN' = b \times N.

Given aa and bb, find the smallest unusual number.

Input

The first line contains aa and bb, separated by a single space. (1≤a≤1061 \le a \le 10^6, 1≤b≤91 \le b \le 9)

Output

Print the smallest unusual number on the first line. If no number satisfies the conditions, print Impossible.

Examples3

  1. Example 1

    Input
    3 1
    
    Expected output
    111
    
  2. Example 2

    Input
    1 3
    
    Expected output
    Impossible
    
  3. Example 3

    Input
    12 4
    
    Expected output
    102564102564