#620
Unrated
Piling Papers
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John wrote down NN (1N3001\le N\le 300) digits on pieces of paper. For each i[1,N]i\in [1,N], the iith piece of paper contains digit aia_i (1ai91 \leq a_i \leq 9).

The cows have two favorite integers AA and BB (1AB<10181\le A\le B< 10^{18}), and would like you to answer QQ (1Q51041\le Q\le 5\cdot 10^4) queries. For the iith query, the cows will move left to right across papers liril_i\dots r_i (1liriN1\le l_i\le r_i\le N), maintaining an initially empty pile of papers. For each paper, they will either add it to the top of the pile, to the bottom of the pile, or neither. In the end, they will read the papers in the pile from top to bottom, forming an integer. Over all 3rili+13^{r_i-l_i+1} ways for the cows to make choices during this process, count the number of ways that result in the cows reading an integer in [A,B][A,B] inclusive, and output this number modulo 109+710^9+7.

입력

The first line contains three space-separated integers NN, AA, and BB.

The second line contains NN space-separated digits a1,a2,,aNa_1, a_2, \dots, a_N.

The third line contains an integer QQ, the number of queries.

The next QQ lines each contain two space-separated integers lil_i and rir_i.

출력

For each query, a single line containing the answer.

예제 입력 1

5 13 327
1 2 3 4 5
3
1 2
1 3
2 5

예제 출력 1

2
18
34

점수

Inputs 2-3: B<100B<100Inputs 4-5: A=BA=BInputs 6-13: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.