#P9870. G. Sum of Binomial Coefficients

G. Sum of Binomial Coefficients

G. Sum of Binomial Coefficients

Problem Description

Given an increasing sequence AA of length mm. There are qq queries, each given N,RN, R, calculate:

$$\left(\sum_{i=1}^R \binom{N}{A_i}\right) \bmod {998244353} $$

Input

The first line of the input contains two integers m,qm, q (1m,q<2171 \le m, q < 2 ^ {17}) - the length of AA and the number of queries. The second line contains mm integers A1,A2,,AmA_1, A_2, \dots, A_m (1A1<A2<<Am<2171 \le A_1 < A_2 < \dots < A_m < 2 ^ {17}). Each of the following qq lines contains two integers N,RN, R (1N1091 \le N \le 10 ^ 9, 1Rm1 \le R \le m).

Output

For each query, print a single integer - the answer of the query, modulo 998244353998244353.

Sample Input

6 10
2 4 5 6 8 10
5 2
5 1
4 3
8 5
5 2
5 1
10 6
7 6
6 2
8 6

Sample Output

15
10
7
183
15
10
763
84
30
183

Hint

There is a template for polynomial operations in this link.

Source

2023“钉耙编程”中国大学生算法设计超级联赛(7)