Under construction

Still being built. Things may change

Doll Claw Machine

Time limit2sMemory limit512 MB

Summary
Given p, c, and n, find the expected number of dolls after exactly k runs for each k up to n, modulo 1000000007.
Level

Medium6 of 10

Topics
Dynamic programming, Probability, Math
Solved
No attempts yet

Statement

Each time the machine runs, it dispenses a doll with probability p=abp = \frac{a}{b}. However, if no doll came out in the previous c−1c - 1 runs, a doll is dispensed with certainty regardless of pp.

Given pp, cc, and nn, find for every natural number k≤nk \le n the expected number of dolls obtained after exactly kk runs.

Input

The input consists of TT test cases. The first line contains the integer TT. (1≤T≤1 000 000)(1 \le T \le 1\,000\,000)

Each test case is one line containing the integers p′p', cc, and nn, separated by spaces. p′p' is the probability that a doll comes out. (0≤p′≤109+6; 1≤c,n≤106)(0 \le p' \le 10^9+6;\ 1 \le c, n \le 10^6) Here p′≡a×b−1(mod109+7)p' \equiv a \times b^{-1} \pmod{10^9 + 7}. (b≢0(mod109+7))(b \not\equiv 0 \pmod{10^9+7})

The sum of nn over all test cases is at most 10610^6.

Output

For each test case, print nn lines. On line kk, print the expected number of dolls obtained after exactly kk runs, modulo 109+710^9+7. Precisely, if the answer can be written as xy\frac{x}{y} for natural numbers xx and yy, print x×y−1(mod109+7)x \times y^{-1} \pmod{10^9+7}.

Examples1

  1. Example 1

    Input
    1
    500000004 2 5
    
    Expected output
    500000004
    250000003
    875000008
    62500003
    968750010