Solution of YVNUM (Yalalovichik Numbers) [DEC COOK-OFF 18]

I tried to solve the problem (YVNUM) in a simple way using strings.
I am getting correct answer but not able to convert it into any long long integer and represent the answer in the form of modulo 10^9+7.
Can you please help me out in correcting my code ???