Problem11008--Beautiful Trees Cutting

11008: Beautiful Trees Cutting

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

It’s universally acknowledged that there’re innumerable trees in the campus of HUST.
One day Xiao Ming is walking on a straight road and sees many trees line up in the right side. Heights of each tree which is denoted by a non-negative integer from 0 to 9 can form a tree string. It's very surprising to find that the tree string can be represent as an initial string repeating $K$ times. Now he wants to remove some trees to make the rest of the tree string looks beautiful. A string is beautiful if and only if the integer it represents is divisible by five. Now he wonders how many ways there are that he could make it.
Note that when we transfer the string to a integer, we ignore the leading zeros. For example, the string “00055” will be seen as 55. And also pay attention that two ways are considered different if the removed trees are different. The result can be very large, so printing the answer (mod 1,000,000,007) is enough. And additionally, Xiao Ming can't cut down all trees.

Input

The first line contains a single integer $K\ (1≤k≤10^9)$, which indicates that the tree string is the initial string repeating $K$ times.
The second line is the initial string $S\ (1≤∣S∣≤10^5)$.

Output

A single integer, the number of ways to remove trees mod 1,000,000,007.

Sample 1 Input

1
100

Sample 1 Output

6
Initially, the sequence is ‘100’. There are 6 ways:
100
1_0
10_
_00
__0
_0_

Sample 2 Input

3
125390

Sample 2 Output

149796

HINT

牛客网

Source/Category