Wesley creates a graph G that contains N vertices. For each pair of vertices u,v, there is a probability of qp that an edge exists between u and v. The probabilities are independent of each other.
Let ∆(G) denote the number of triangles in G. A triangle is a set of 3 vertices that are connected by 3 edges.
Please help Wesley find the expected value of (∆(G))2.
Line 1 contains integer T (1≤T≤106), the number of cases. T lines follow. The ith line contains integers N, p, q (3≤N≤106, 1≤p<q≤106), separated by spaces.
Output T lines, one line for each case. Suppose the answer to the ith case is QP, in lowest terms. Output PQ−1(mod109+7). That is, output a number R such that 0≤R<109+7 and P≡RQ(mod109+7).