Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

HS11DIVS - Count the numbers!

For given integers a and b your task is to find how many integers in the range [a,b] are divisible by a number x, and have the additional property that the sum of their digits lies in the range [l,r] for given l,r.

Input

In the first line you're given a and b ( 1 <= a <= b < 10^100 ).
In the second line you're given three positive integers x ( 1 <= x <= 10 ), l, r ( 1 <= l <= r <= 1,000 ).

Output

In the first and only line output the result modulo 1,000,000,007.

Example

Input:
1 100
5 10 50

Output:
5

Scoring

By solving this problem you score 10 points.


Added by:Damir Ferizovic
Date:2011-08-31
Time limit:0.400s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 CLOJURE PERL6
Resource:High School Programming League 2011/12

hide comments
2014-12-15 22:33:12 Nikola Krstic
So, very basic problem, easy to solve. Just input 2 numbers, loop from one to other and check if firts is divisible with x. If it is sum the digits of first number compare it with L and R. If it fits, sum++, else do nothing and back the sum of digits to 0. Easy? :D
2012-03-18 20:17:55 pratibha


Last edit: 2012-03-25 18:50:57
2012-03-13 20:25:01 hariprasath
can anyone explain this problem
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.