using System; using System.Collections; using System.Collections.Generic; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ for(int t=0;tlong.Parse(e)); long N=d[0];long K=d[1]; if(typ=='C'){ Console.WriteLine(cal_nCrMod(N,K)); continue; } if(typ=='P'){ long x=cal_nCrMod(N,K)*FactorialMod(K); Console.WriteLine(x%mod); continue; } if(typ=='H'){ if(N==0 && K==0){ Console.WriteLine(1); continue; } Console.WriteLine(cal_nCrMod(N+K-1,K)); continue; } } } long Max; long mod; String[] In; int T; public Sol(){ mod=(long)(1e9+7); Max=(int)3e6; FM=new long[Max]; FM[0]=1; for(int i=1;imod)n%=mod; if(n==0)return 0; //(mod-2)乗を返す List L=new List(); int idx=0; while(mod>(0x1<0){ ret*=Table[i]; ret%=mod; } } return ret; } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(){return Console.ReadLine().Split(' ');} static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));} static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));} static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));} }