


S = “[1, [2, 3], [4, [5, 6] ] ]”
Total depth = 1*1 + 2*2 + 3*2 + 4*2 + 5*3 + 6*3 = 52
1. The given string may be empty.
2. The string will not contain any white spaces.
3. You have to take the modulo with 10 ^ 9 + 7 as the answer may be very large.
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain a string ‘S’ which denotes the given nested list.
For each test case, print a single line containing a single integer denoting the goodness of the given string.
The output for every test case will be printed in a separate line.
You don’t need to print anything; It has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= |S| <= 100000
1 <= ES[ i ] <= 10^5
Where “|S|” is the length of the given string, “ES[ i ]” is the element/number stored in the string at the “i-th” position.
Time limit: 1 sec
The basic idea is to traverse through the complete string, make a variable to hold the current depth and whenever found a number just add it into our answer after multiplying it with the current depth.