#t253. 回文数

回文数

Palindrome Number

Problem Description

If a number (with no leading zero) reads the same from left to right as from right to left, we call it a palindrome number.

For example, given the decimal number 5656, adding 56+6556 + 65 (i.e. reading 5656 backwards) gives 121121, which is a palindrome.

Another example, for the decimal number 8787:

  • STEP1: 87+78=16587 + 78 = 165
  • STEP2: 165+561=726165 + 561 = 726
  • STEP3: 726+627=1353726 + 627 = 1353
  • STEP4: 1353+3531=48841353 + 3531 = 4884

Here one "step" means one addition in base NN. The example above reaches the palindrome 48844884 in 44 steps at least.

Write a program that, given an NN-ary number MM (2≤N≤102 \le N \le 10 or N=16N = 16, and MM has at most 100100 digits), computes the minimum number of steps to obtain a palindrome. If it is impossible to obtain a palindrome within 3030 steps (inclusive), output Impossible!.

Input Format

Two lines: NN and MM, respectively.

Output Format

If a palindrome can be obtained within 3030 steps, output in the form STEP=ans, where ans\text{ans} is the minimum number of steps. Otherwise output Impossible!.

Sample Input

Sample Input 1

10
87

Sample Output

Sample Output 1

STEP=4