SP12240 HS12MULT - Multinomial numbers

Description

You may perhaps know how to find the last nonzero digit of n factorial. This time your task is harder, find the last nonzero decimal digit of the multinomial coefficient: (a $ _{1} $ +a $ _{2} $ + … +a $ _{n} $ )!/(a $ _{1} $ !\*a $ _{2} $ !\* … \*a $ _{n} $ !) . Note that this is an extension of the classical problem, since factorials (and binomial numbers) are also multinomial numbers!

Input Format

An integer _T_, denoting the number of testcases (_T_

Output Format

Output _T_ lines, the case number followed by the last nonzero decimal digit. See the sample output for the correct format!