| Robbing Balloons 2.0 Qualifications |
|---|
| Finished |
Ahmad needed to stop gifting people an array of integers, so he decided to gift Monther a bunch of intervals this time!
Ahmad gifted Monther $$$n$$$ intervals, and he is interested in the number of ways you can choose one integer from each of the $$$n$$$ intervals such that the sum of these integers is divisible by $$$k$$$.
More formally, he is interested in the number of ways to choose $$$n$$$ integers $$$x_1, x_2, \ldots, x_n$$$ where ($$$l_i \leq x_i \leq r_i$$$) and their sum $$$\sum_{i=1}^{n}x_i$$$ is divisible by $$$k$$$.
The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^3)$$$ – the number of test cases.
The first line of each test case contains two integers $$$n$$$ and $$$k$$$ $$$(1 \leq n \leq 2 \cdot 10^5; 1 \leq k \leq 10)$$$.
The next $$$n$$$ lines of the test case each contain two integers $$$l_i$$$ and $$$r_i$$$ $$$(1 \leq l_i \leq r \leq 10^9)$$$.
It's guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2\cdot 10^5$$$.
For each test case, print the number of ways you can choose an array $$$x$$$ as described above modulo $$$10^9 + 7$$$.
32 31 31 33 31 41 51 64 41 121 141 151 20
3 40 12600
| Name |
|---|


