The MTM Machine |

The MTM is one of the first digital machines ever designed. The aim of the machine is to process positive integer numbers, but due to the primitive nature of the machine only some numbers are accepted for processing; such numbers are called *acceptable*. When a number is accepted by MTM, the machine outputs another number, according to the rules stated below. When a number is not accepted, the machine simply outputs `NOT ACCEPTABLE`.

A number is a non empty string of decimal digits. Given two numbers *N* and *M*, when we write *NM* we mean the number formed by the digits of *N* followed immediately by the digits of *M*. For example, if *N* is 856 and *M* is 112 then *NM* is 856112. For any number *X*, the associate of *X* is the number *X*2*X*. For example, the associate of 78 is 78278.

We say that a number *X* *produces* a number *Y*, if number *X* is acceptable and when given as input to the machine MTM, the number returned by the machine is *Y*.

The behaviour of the MTM machine is governed by the following rules:

**Rule 0:**- A number containing the digit 0 (zero) is not acceptable.
**Rule 1:**- Given any number
*X*not containing a digit zero, then number 2*X*produces*X*. For example, 234 produces 34. **Rule 2:**- Given any pair of numbers
*X*,*Y*, if*X*produces*Y*then 3*X*produces the associate of*Y*. For example, 25 produces 5 by Rule 1, so 325 produces 525. **Rule 3:**- No other numbers are acceptable.

Your task here is to write a program that simulates the MTM machine.

You may assume that the largest number output by the machine has at most 1000 digits.

20 22 42 32 33289 0

NOT ACCEPTABLE 2 NOT ACCEPTABLE NOT ACCEPTABLE 89289289289