Period Sequence

n개의 값으로 만든 주기 수열에서 거대한 구간 [a,b] 안의 모든 부분 배열에 대해 값 곱하기 등장 횟수의 제곱을 합한 값을 구한다.

어려움8수학조합론누적 합구현아직 제출이 없습니다시간 제한6초메모리 제한256 MB

문제

Chiaki has nn integers s_0,s_1,,s_n1s\_0,s\_1,\dots,s\_{n-1}. She has defined an infinite sequence SS in the following way: S_k=s_kmodn+nknS\_k = s\_{k \bmod n} + n \cdot \lfloor \frac{k}{n} \rfloor, where kk is a zero based index.

For a continuous subsequence S\[l..r]S\[l..r], let cnt_xcnt\_x be the number of occurrence of xx in the subsequence S\[l..r]S\[l..r]. Then the value of S\[l..r]S\[l..r] is defined as follows f(l,r)=_xxcnt2_xf(l,r)=\sum\limits\_{x}x \cdot cnt^2\_x

For two integers aa and bb (aba \le b), Chiaki would like to find the value of (_alrbf(l,r))mod(109+7)(\sum\limits\_{a \le l \le r \le b} f(l,r)) \bmod (10^9+7)

입력

There are multiple test cases. The first line of input contains an integer TT, indicating the number of test cases. For each test case:

The first line contains three integers nn, aa and bb (1n2000,0ab10181 \le n \le 2000, 0 \le a \le b \le 10^{18}).

The second line contains nn integers s_0,s_1,,s_n1s\_0,s\_1,\dots,s\_{n-1} (0s_i1090 \le s\_i \le 10^9).

It is guaranteed that the sum of all nn does not exceed 21042 \cdot 10^4.

출력

For each test case, output an integer denoting the answer.