beecrowd | 3374

# F of a and b to the k

By ACM International Collegiate Programming Contest, Kuwait University United Arab Emirates

Timelimit: 1

Consider the following function: Given a pair of values <V,K>, write a program to determine if there are values for a, b, and k satisfying all of the following:

0 < a b < 10
0 ≤ kK
k (a,b) = V

## Input

Your program will be given a series of pairs <V ,K>, each pair on a separate line. Note that 0 ≤ V < 1,000, 000.

The end of the input file is identified by a dummy pair (which is not part of the test cases) where both V and K are 0.

## Output

For each given pair <V ,K>, if there are values for ab,and k satisfying the requirements, write on a separate line, the following output:

f^k(a,b)=V

If there is more than one solution, print the solution with the smallest value of k within all the solutions with the smallest value of b within all the solutions with the smallest value of a. (In other words, the first solution if they were sorted lexicographically in an ascending order using the key <a,b,k>.)

If there is no solution, print the following:

"no solution for <V,K>"

 Input Sample Output Sample 5 10 5 1 34 3 34 4 34 20 0 0 f^4(1,1)=5 f^1(1,5)=5 no solution for <34,3> f^4(5,8)=34 f^8(1,1)=34