Description: Problem input
Inputs include multiple test cases, test cases given first number N, then given N test cases, including a line for each test case, the first number given sequence of positive integers M, then turn gives M a positive integer, a ≤ N ≤ 100000,2 ≤ M ≤ 500000, positive integer size does not exceed 1000.
Problem Output
For each test case, output a line, given after a series of positive integers transform any number of times to obtain the minimum sum.
Sample Input
2
424816
3322
Sample Output
8
3
To Search:
File list (Check if you may need any files):
D.doc