Math Olympiad is called “Aoshu” in China. Aoshu is very popular in elementary schools. Nowadays, Aoshu is getting more and more difficult. Here is a classic Aoshu problem:
The first line of the input is an integer T( T <= 20) indicating the number of test cases.
Each test case is a line which is in the format below:
s1 s2 s3
s1, s2 and s3 are all strings which are made up of capital letters. Those capital letters only include 'A','B','C','D' and 'E', so forget about 'F' to 'Z'. The length of s1,s2 or s3 is no more than 8.
When you put a '=' between s2 and s3, and put a operator('+', '-', '×' or '÷'.) between s1 and s2, and replace every capital letter with a digit, you get a equation.
You should figure out the number of solutions making the equation right.
Please note that same letters must be replaced by same digits, and different letters must be replaced by different digits. If a number in the equation is more than one digit, it must not have leading zero.
For each test case, print an integer in a line. It represents the number of solutions.
2 A A A BCD BCD B
5 72