long f[1<<20]; P=1e9+7; i,c,r; p(long a,int i){r=i?p(a*a%P,i/2)*(i%2?a:1)%P:1;} main(n){ gets(f); for(*f=n;r++<1e6;f[r]=f[r-1]*r%P); for(;i=~scanf(" %c(%d,%d)",&c,&n,&r);printf("%d\n",n