long f[1<<21],k;P=1e9+7,x,c;p(a,i){k=i?p(1L*a*a%P,i/2),i%2?k*a%P:k:1;}main(n){for(gets(f),*f=1;k++<2e6;f[k]=f[k-1]*k%P);for(;x=~scanf(" %c(%d,%ld)",&c,&n,&k);printf("%d\n",n>=k?p(f[n-k]*(c%5?f[k]:1)%P,P-2),k*f[n]%P:0))c&8&&(n+=k)&&n--;}