SP1457 BLUEEQ - Help Blue Mary Please! (Act I)
Description
This morning Blue Mary wrote some equations on a piece of paper and left it on her desk. After solving some problems in SPOJ, she found that her classmate H.L. replaced all characters on the paper with some other ones. H.L. told her he replaced the same characters with the same ones, and different characters with different ones because of his goodness. Now Mary needs your help to get the original equations back.
In Mary's equations, only 13 characters appear:0,1,2,3,4,5,6,7,8,9,+,\*,=. There is one and only one "=" in each equation. In H.L.'s equations,only 13 Latin letters appear: a,b,c,d,e,f,g,h,i,j,k,l,m. All the equations are correct in decimal notation.
For example. If Mary wrote down 2+29=31, H.L. replaced 2 with i, + with l, 9 with k, = with e, 3 with m and 1 with a, we got ilikema .
Input Format
The first line contains a single integer t.t blocks follow.
To every block,the first line contains a single integer n(1
Output Format
If there doesn't exist n equations that can be translated to H.L.'s equations,print a line contains the word _noway_ .Otherwise you should output all the corresponding relations that can be fixed in lexicographic order,see the example.