The biosphere is made up of the parts of Earth where life exists—all ecosystems. The biosphere extends from the deepest root systems of trees, to the dark environments of ocean trenches, to lush rain forests, high mountaintops, and transition zones like this one, where ocean and terrestrial ecosystems meet.
RANGE SUM QUERY 2.0
Problem Statement
Amy has an array A of R-L+1 integers such that A1 = L, A2 = L+1, …. , AR-L+1 = R.
Anne gives her Q queries. Each query consists of two integers X and Y.
Anne wants Amy to check if there exists at least one subsequence in A, such that the sum of subsequence lies between X and Y (both inclusive).
You are given T independent test cases.
NOTE: Subsequence of an array can be obtained by erasing some (possibly zero) elements from the array. You can erase any elements, not necessarily going successively. The remaining elements preserve their order.
Constraints
1 <= T <= 3
1 <= Q <= 105
1 <= L <= R <= 109
1 <= X<= Y <= 1018
All input values are integers.
Input Format
First-line contains T.
First line of each test case consists of a three space separated integers integer Q, L and R.
Next Q lines of each test case consists of two space separated integers X and Y.
Output Format
Print in a newline for each query: 1 if there exists a required subsequence otherwise print 0.
Sample Input 1
1
2 1 3
6 7
9 9
Sample Output 1
1
0
Explanation of Sample 1
For the 1st query, subsequence S = { A1, A2, A3} has sum 6 (A1+A2+A3 = 1+2+3 = 6). So, there is one possible subsequence whose sum lies between X = 6 and Y = 7.
For 2nd query, there is no possible subsequence.