Chosen by god

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

Everyone knows there is a computer game names "hearth stone", recently xzz likes this game very much. If you want to win, you need both capacity and good luck.

There is a spell card names "Arcane Missiles", which can deal 3 damages randomly split among all enemies.

xzz have a "Arcane Missiles Plus" can deal n damage randomly split among all enemies. The enemy battle field have only two characters: the enemy hero and enemy minion.

Now we assume the enemy hero have infinite health, the enemy minion has m health.

xzz wants to know the probability of the "Arcane Missiles Plus" to kill the enemy minion (the minion has not more than 0 health after "Arcane Missiles Plus"), can you help him?

Input

The first line of the input contains an integer T, the number of test cases. T test cases follow. (1 ≤ T ≤ 100000)

Each test case consists of a single line containing two integer n and m. (0 ≤ m ≤ n ≤ 1000)

Output

For each test case, because the probability can be written as x / y, please output x * y^-1 mod 1000000007. .(y * y^-1 ≡ 1 mod 10^9 + 7)

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

T^T Online Judge

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