A proper string is defined as a string whose every index has either 'S'(denotes safe index), else has the count of adjacent safe indexes to the current index. So for any index values possible are $,0,1,2 satisfying the above mentioned condition. Given a string with some missing entries (denoted by "X') your task is to count the number of ways the missing indexes in the string can be filled to get a "proper" string.
Input:
string s with characters S/0/1/2/X.
X denotes empty index and S denotes safe index.
(1<-string size <-100000)
Output:
Print the number of ways empty indexes can be filled to create a proper string modulo 10^9+7.
Sample:
X1X
2($10,015)
2X
0 (not possible)
8(000, 150, 051, 510, S51, 155, S25, SSS)
Can you solve it ?