import re p=re.compile(r'\(|\)|,') M=10**9+7;UN=10**6 F=[0]*(2*UN+1);FI=[0]*(2*UN+1);F[0]=FI[0]=1 for i in xrange(1,2*UN+1):F[i]=(i*F[i-1])%M;FI[i]=pow(i,M-2,M)*FI[i-1]%M for i in xrange(input()): q=p.split(raw_input());N,K=map(int,q[1:3]) if q[0]=="C":A=[(F[N]*FI[K]*FI[N-K])%M,0][N