Not So Flat After All

No attempts yetTime limit1sMemory limit128 MB

Problem

Every positive integer $v$ can be written as $v = p_1^{a_1} \cdot p_2^{a_2} \cdots p_n^{a_n}$, where each $p_i$ is a prime and every $a_i \ge 0$. For example, $24 = 2^3 \cdot 3^1$.

Pick two distinct primes $p_1 \ne p_2$. Consider a two-dimensional plane on which the exponent of $p_1$ is the x-coordinate and the exponent of $p_2$ is the y-coordinate. Any number of the form $p_1^{a_1} \cdot p_2^{a_2}$ is then the point $(a_1, a_2)$.

This idea extends to any $N$-dimensional space in which each of the $N$ axes is assigned a distinct prime. Every such space has a unique set of primes, which we call the Space Identification Set $S$; its size $|S|$ equals $N$. Any number that is a product of primes taken only from $S$ (each raised to an exponent $\ge 0$) can be plotted in this $|S|$-dimensional space. Naturally, any number plottable in space $A$ is also plottable in space $B$ whenever $S_A \subseteq S_B$.

The distance between two points is the number of unit steps needed to travel from one to the other along the grid lines, where every move is parallel to a single axis. This equals the Manhattan (L1) distance between the two coordinate vectors. For instance, $168 = 2^3 \cdot 3 \cdot 7$ and $882 = 2 \cdot 3^2 \cdot 7^2$ are at distance $|3-1| + |1-2| + |1-2| = 4$.

Given two positive integers, determine the minimum size of a space in which both numbers can be plotted, and the distance between the two numbers in that space.

Input

The input contains one or more test cases. Each test case is a single line with two positive integers $A$ and $B$ ($0 < A, B < 1{,}000{,}000$) satisfying $A \cdot B > 1$. The input ends with a line containing two zeros, which must not be processed.

Output

For each test case, print one line in the form:

k. X:D

where $k$ is the test case number (starting from 1), $X$ is the minimum size of a space in which both $A$ and $B$ can be plotted, and $D$ is the distance between the two numbers in that space.