#include #include #include const int MOD = 1e9 + 7; template struct Combination { std::vector fac, inv, finv; Combination(int n=1e6): fac(n), inv(n), finv(n) { fac[0] = fac[1] = inv[1] = finv[0] = finv[1] = 1; for(Int i=2; i com(1e6+10); while(t--){ getchar(); char c = getchar(); int n, k; scanf("(%d,%d)", &n, &k); if(c=='C') printf("%ld\n", com.C(n, k)); if(c=='P') printf("%ld\n", com.P(n, k)); if(c=='H') printf("%ld\n", com.H(n, k)); } return 0; }