AlgoUniversity
  • Go Back
Discussion
Count Integers :

Author

Shikhar Mehrotra

Difficulty Level : Medium

Submissions : 145

Asked In : Optum

Marks :20

: 3 | : 0

You are given 4 integers $$$L,R,X,Y$$$.

Your task is to count how many numbers exist between $$$L$$$ and $$$R$$$ are there (both inclusive) with given property:

The count of digits with odd frequency $$$=X$$$ and count of digits with even frequency $$$=Y$$$

Consider digits with $$$0$$$ frequency as even frequency.

Since the answer could be very large, return the answer modulo $$$10^{9}+7$$$

Input

The input consists of 4 space separated integers as: $$$L$$$ $$$R$$$ $$$X$$$ $$$Y$$$

$$$X$$$ + $$$Y$$$ = $$$10$$$

$$$1 \le L \le R < 10^{1000} $$$

Output

Print the count of such integers described in the above problem statement modulo $$$10^9+7$$$ .

Examples

Input
1 1000 0 10
Output
9
Input
1 1000 10 0
Output
0

Note

In first test case where $$$L=1$$$, $$$R=1000$$$, $$$X=0$$$, $$$Y=10$$$.

Following are the solutions $$$11,22,33,44,55,66,77,88,99$$$.

All satisfy the above given property.

For Example consider $$$11$$$

digitfrequency
00
12
20
30
40
50
60
70
80
90
Since there are 10 digits with even frequency and $$$0$$$ digits with odd frequency in $$$11$$$ . Hence it is valid

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.