Hide

Problem C
Guess the Digits

Filip came across an interesting math problem: He was supposed to find a five-digit number with the following property. If you cross out its first two digits, then place the digit $8$ after the remaining three digits to form a four-digit number and multiply the resulting four-digit number by $4$, you will get the original five-digit number.

After thinking for a while, he found his answer. But now he is wondering, what if he had to find an $m$-digit number, where you have to cross out the first $n$ digits, place a (possibly multi-digit) number $p$ after the remaining $(m-n)$-digit number, then multiply this new number by a number $q$ to get the original number? Please help him!

(You may assume that $m$, $p$, and $q$ start with a non-zero digit, and $n$ is either $0$ or starts with a non-zero digit. The $(m-n)$-digit number also needs to start with a non-zero digit.)

Input

The input consists of a single line containing four numbers: $m$, $n$, $p$, and $q$. You may assume that each number is positive and not larger than $1\, 000\, 000$. You may also assume that $m\geq n$.

Output

The output consists of a single line. If such an $m$-digit number exists, the line contains the smallest such number. If no such number exists, the line contains the string IMPOSSIBLE.

Sample Input 1 Sample Output 1
5 2 8 4
20512
Sample Input 2 Sample Output 2
2 1 11 4
IMPOSSIBLE

Please log in to submit a solution to this problem

Log in