You are given a number. You want to compute the sum of all possible resulting numbers after applying the magic operation.
In a magic operation, you pick a non-empty subsequence from this number, then take these digits out of the number. The remaining digits then fill in the gap, and the number after the magic operation is the integer that is left.
For eg: Let's say the number is 12345. One of the subsequences of this number is 24. So after removing this subsequence, the resulting number is 135.
Leading zeros are allowed in the resulting number (number after applying the magic operation). When all digits are removed, the number is considered to be 0.
Input Format:
Output Format:
For each test case output in a seperate line:
The sum of all possible resulting numbers after applying the magic operation modulo (109+7).
Constraints:
Let's consider the first test case.
Non-Empty Subsequences we can remove from the given number are : 2,0,3,20,23,03,203
After removing these digits, the resulting numbers are 03,23,20,3,0,2,0 respectively. The sum of all the resulting numbers is 51 which is the answer.