#P7609. [2018年杭电多校]sacul

[2018年杭电多校]sacul

sacul

Problem Description

Patrick Star found a kind of magical matrixs, he named them HMBBHMBB !!! We use pp to express the cc-th prime number. The size of HMBBiHMBB_i is pipip^i * p^i ! What is more surprising is that :

  1. For any nn, the element on the i-th row j-th column HMBBn[i][j]HMBB_n[i][j] = (C(i,j) mod p)>0)(C(i, j)\ mod\ p) > 0) ? 11 : 00.
  2. Where C(i,j)C(i, j) is count of method to choose jj balls (unordered) from ii balls which are pairwise distinct.
  3. Note that rows and columns both count from zero. Patrick Star defined F[n][k]F[n][k] the sum of all elements of (HMBBn)k(HMBB_n)^k, $F[n][k] = \sum_{i = 0}^{p^n-1}\sum_{j=0}^{p^n-1}HMBB_n^k[i][j]$ Now Patrick wants to know (i=1nj=1kF[i][j]) mod (109+7)(\sum_{i=1}^n\sum_{j=1}^kF[i][j])\ mod\ (10^9 + 7) !

Input

The first line contain a integer TT (no morn than 10), the following is TT test case, for each test case : Each line contains contains three integer c, n, k (0<n1090 < n \le 10^9, 0<c,k1050 < c, k \le 10^5). Separated by an white space.

Output

For each test case output one line denotes the answer that Patrick Star wants to know.

Sample Input

1

1 1 1

Sample Output

3

Source

2018 Multi-University Training Contest 6