The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case starts with a line contains only one integer n (0 < n <= 20), indicating the number of simple series circuits. Next n lines are the descriptions of each simple series circuit. The wire is consisted by the character “-”. And resistances are show by positive integers, means their resistance values. The line’s length is shorter than 100 characters, and the count of resistance in each simple series circuit is no more than 20.
I assure all the calculations by integers using in this problem will not overflow the integer.