You are given a string s consisting of digits from 0 to 9(both inclusive). You can insert ‘+’ between any two characters of the string (maybe none). The resultant string has to be a valid mathematical expression.
Numbers having leading zeros are considered valid.
Example: Consider the string 406 : “406+,4++06,+406” etc. are not valid mathematical expressions.
Whereas “4+06,40+6,4+0+6,406” are valid.
You need to evaluate all the valid mathematical expressions and print the sum of all results.
First line of input contains an integer T, the number of test cases.
T lines follow, each containing a string S, containing only numeric characters.
Output contains T lines each having the answer corresponding to each test case.
1 ≤ T ≤ 10
1 ≤ | S | ≤ 10, where | S | denotes length of string
All the valid mathematical expressions are as follows:
Final Answer is 406+10+46+10 = 472