AlgoUniversity
  • Go Back
Discussion
Beautiful Numbers :

Author

Shikhar Mehrotra

Difficulty Level : Hard

Submissions : 648

Asked In : Trilogy-Innovations

Marks :50

: 8 | : 1

A number is beautiful if the xor sum of the digits of the number is strictly greater than the average of the minimum and maximum digit of the number. Given $$$A$$$ and $$$B$$$, find the count of beautiful numbers in the range $$$[A, B]$$$.

Since the answer can be very large, output the remainder after dividing the answer by $$$10^{6}+7$$$

Note: The xor sum of the digits of a number is the bitwise XOR of all its digits.

Input

The input consist of two space-separated integers $$$1\le A\le 10^{18}$$$ $$$1\le B\le 10^{18}$$$

Output

Output number of beautiful integers in range $$$[A,B]$$$ modulo $$$10^{6}+7$$$

Examples

Input
32 35
Output
2
Input
10 12
Output
2

Note

First Test Case

For 32, xor sum = 1, average of maximum and minimum digit is 2.5

For 33, xor sum = 0, average of maximum and minimum digit is 3

For 34, xor sum = 7, average of maximum and minimum digit is 3.5

For 35, xor sum = 6, average of maximum and minimum digit is 4

The beautiful numbers are 34 and 35.

Second Test Case

For 10, xor sum = 1, average of maximum and minimum digit is 0.5

For 11, xor sum = 0, average of maximum and minimum digit is 1

For 12, xor sum = 3, average of maximum and minimum digit is 1.5

The beautiful numbers are 10 and 12.

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.