A. Sole Occupancy
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given $$$N$$$ of sticks. The length of the $$$i$$$-th stick is denoted by $$$L_i$$$. You have to arrange each of these sticks horizontally on a line of cells in the range $$$[1, \infty ]$$$. It can happen that two or more sticks overlap with each other, so a cell can be occupied by more than one stick.

You have to answer $$$Q$$$ queries.

For every query, you are given two integers $$$R$$$ and $$$K$$$, you have to answer with YES if and only if there exists an arrangement of the sticks such that all the below conditions are satisfied:

  • Any stick of length $$$P$$$ occupies $$$P$$$ consecutive cells in the range $$$[1, R]$$$ (both inclusive).
  • There are exactly $$$K$$$ cells in the range $$$[1,R]$$$ (both inclusive) that are occupied by a single stick.

Else answer with NO.

Input
  • The first line contains $$$T$$$, the number of testcases. Then the testcases follow, each consisting of $$$2 + Q$$$ lines.
  • The first line of each testcase contains two space separated integers denoting $$$N, Q$$$.
  • The second line of each testcase contains $$$N$$$ space separated integers denoting $$$L_1, L_2, \ldots L_N$$$
  • The next $$$Q$$$ lines of each testcase contains two space separated integers denoting $$$R,K$$$.

Constraints

In all inputs,

  • $$$1 \le T \le 1000$$$
  • $$$1 \le N, Q \le 3 \cdot 10^5$$$
  • $$$1 \le L_i \le 10^9$$$
  • $$$\displaystyle \max_{i=1}^{N} L_i \le R \le \sum_{i=1}^{N} L_i$$$
  • $$$0 \le K \le R$$$
  • The sum of $$$N$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$
  • The sum of $$$Q$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$
Output

For each testcase, print either "YES" or "NO" (without quotes). Note that the answer is case-insensitive.

Example
Input
2
5 3
1 2 3 4 5
15 15
7 2
8 6
3 2
1 3 1
4 0
5 3
Output
YES
YES
NO
NO
YES
Note

Below is a possible arrangement for the second query of the second test case.