| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 5 | 4 | 3 | 100.000% |
Nikita is preparing for a competition. The most challenging part of this task is to find a pair of matching socks. In the drawer, there are $p$ different pairs of socks, as well as $m$ single socks whose pairs he has lost long ago. Nikita takes socks one by one until he finds two matching socks among those he has pulled out. What is the expected number of socks Nikita will pull out?
Calculate this expected value modulo the prime number 10ドル^9 + 7$. Specifically, if the answer is a rational number $x / y,ドル you need to output a number $a$ such that 0ドル \le a < 10^9 + 7$ and $a \cdot y = x \pmod{10^9 + 7}$.
The first line contains an integer $t$: the number of test cases (1ドル \le t \le 10^4$). The following lines describe the test cases.
Each test case is given on a separate line containing two integers $p$ and $m$: the number of pairs of socks and the number of single socks in the drawer (1ドル \le p \le 10^6$; 0ドル \le m \le 10^6$).
For each test case, output a line containing a single integer: the answer to the problem.
1 1 1
666666674
In the first test case, the expected value is 8ドル / 3,ドル which equals 666ドル,666円,674円$ modulo 10ドル^9 + 7$.