← Home
write a go solution for Description:
Being bored of exploring the Moon over and over again Wall-B decided to explore something he is made of — binary numbers. He took a binary number and decided to count how many times different substrings of length two appeared. He stored those values in c_00, c_01, c_10 and c_11, representing how many times substrings 00, 01, 10 and 11 appear in the number respectively. For example:

10111100arrowc_00=1,c_01=1,c_10=2,c_11=3

10000arrowc_00=3,c_01=0,c_10=1,c_11=0

10101001arrowc_00=1,c_01=3,c_10=3,c_11=0

1arrowc_00=0,c_01=0,c_10=0,c_11=0

Wall-B noticed that there can be multiple binary numbers satisfying the same c_00, c_01, c_10 and c_11 constraints. Because of that he wanted to count how many binary numbers satisfy the constraints c_xy given the interval [A,B]. Unfortunately, his processing power wasn't strong enough to handle large intervals he was curious about. Can you help him? Since this number can be large print it modulo 10^9+7.

Input Format:
First two lines contain two positive binary numbers A and B (1<=A<=B<2^100,000), representing the start and the end of the interval respectively. Binary numbers A and B have no leading zeroes.

Next four lines contain decimal numbers c_00, c_01, c_10 and c_11 (0<=c_00,c_01,c_10,c_11<=100,000) representing the count of two-digit substrings 00, 01, 10 and 11 respectively.

Output Format:
Output one integer number representing how many binary numbers in the interval [A,B] satisfy the constraints mod 10^9+7.

Note:
Example 1: The binary numbers in the interval [10,1001] are 10,11,100,101,110,111,1000,1001. Only number 110 satisfies the constraints: c_00=0,c_01=0,c_10=1,c_11=1.

Example 2: No number in the interval satisfies the constraints. Output only the code with no comments, explanation, or additional text.