时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
A deck of cards contains

gold coin cards,

prohibition cards and

bomb cards.
Now shuffle the stack randomly and draw cards one by one until the stack is empty or the game is over.
1. If you draw a gold coin card, get it and continue the game.
2. If you draw a prohibition card, end the game.
3. If you draw the bomb card, discard all the gold cards you have obtained and end the game.
Calculate the Expectation of the number of gold coin cards that can be obtained after the game.
输入描述:
The input consists of multiple test cases.The first line contains a single integer
)
- the number of test cases. Description of the test cases follows.
each test case contains 3 intergers
)
输出描述:
For each test case, print the expectation, modulo

示例1
输入
复制
3
3 0 0
1 1 1
10000 10000 10000