You are given a long but simple formula in a compressed format. A compressed formula is a sequence of N pairs of an integer ri and a string si, where each si consists only of the digits 0 to 9 and the characters +, -, *. To restore the original formula, repeat si exactly ri times for every i, then concatenate the resulting strings in the order of the sequence.
A restored formula always satisfies the following BNF.
<expression> := <term> | <expression> '+' <term> | <expression> '-' <term>
<term> := <number> | <term> '*' <number>
<number> := <digit> | <non-zero-digit> <number>
<digit> := '0' | <non-zero-digit>
<non-zero-digit> := '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
Here + means addition, - means subtraction, and * means multiplication of integers.
Write a program that computes the value of the given formula modulo 1,000,000,007. Here x modulo m is the non-negative integer r such that some integer k satisfies x=km+r and 0≤r<m. For integers x and m, that r is uniquely determined.