Mind control

TimeLimit:3000MS  MemoryLimit:524MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

There is a wonderful country where people like eating very much. Each person has exactly one direct follower while the follower's follower is also follower of this man (of course the most unattractive man doesn't have his follower).

And you find some amazing cake, if you give it to a person, you can have the trust of this person and all his followers.

Now you want to give out M cakes randomly to N person (each person can get at most one cake), please calculate the expectation of the trust you have earned.

Because the answer can write as a / b, please output a * b^-1 mod 10^9 + 7. (b * b^-1 ≡ 1 mod 10^9 + 7)

Input

First line a single integer T indicating the number of cases. T<=1000000;

For each case, first line two number N and M described before. N, M<=1000000;

Output

A single integer indicating the expectation of the trust you have earned. (mod 1e9 + 7)

SampleInput
2
3 3
3 2
SampleOutput
3
666666674
Submit
题目统计信息详细
总AC数1
通过人数1
尝试人数1
总提交量1
AC率100.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: