Counting Problem
View as PDFGiven two integers  and 
, count the number of ordered pairs of integers 
 in the range 
 such that 
 and 
. Since the answer may be very large, output it modulo 
.
There will be  such test cases.
Constraints
Input Specification
The first line contains an integer .
The new  line contains two integers, 
  and 
.
Output Specification
Output a single integer, the number of pairs modulo .
Sample Input
1
5 6
Sample Output
8
Explanation for Sample
The pairs are , 
, 
, 
, 
, 
, 
, 
.
Comments