Squaring the Triangle

아직 제출이 없습니다시간 제한5초메모리 제한256 MB

문제

Wesley creates a graph GG that contains NN vertices. For each pair of vertices u,v\\{u, v\\}, there is a probability of pq\dfrac{p}{q} that an edge exists between uu and vv. The probabilities are independent of each other.

Let (G)∆(G) denote the number of triangles in GG. A triangle is a set of 33 vertices that are connected by 33 edges.

Please help Wesley find the expected value of ((G))2(∆(G))^2.

입력

Line 11 contains integer TT (1T1061 ≤ T ≤ 10^6), the number of cases. TT lines follow. The iith line contains integers NN, pp, qq (3N1063 ≤ N ≤ 10^6, 1p<q1061 ≤ p < q ≤ 10^6), separated by spaces.

출력

Output TT lines, one line for each case. Suppose the answer to the iith case is PQ\dfrac{P}{Q}, in lowest terms. Output PQ1(mod109+7)PQ^{-1} \pmod {10^9 + 7}. That is, output a number RR such that 0R<109+70 ≤ R < 10^9 + 7 and PRQ(mod109+7)P ≡ RQ \pmod {10^9 + 7}.