Jack feels good with Rose, as Rose is a master of math. However, Rose sets a higher standard on Jack, to improve Jack's ability of math. So today Rose as usual sets a math question to Jack.
Given an integer

and a sequence

,

,

,

, one position is

if and only if there exists

where

, and the weight of this sequence
)
is defined as the number of Good positions in this sequence.
Given

and

, for every

between

and

(

and

included), calculate
)
.
Note that

is the set of sequences satisfying

.
Each output should module

.