#include #include #include #include #include using namespace std; #define N 30 #define M 100009 #define LL long long #define MOD 1000000007LL int mat[N][M]; char s[M]; LL fac[M]; void update(int index, int x){ while(index0){ sum += mat[x][index]; index -= (index&(-index)); } return sum; } LL big_mod(LL base, LL pw){ if(pw==0)return 1; LL tmp = big_mod(base, pw/2); tmp = (tmp * tmp)%MOD; if(pw%2){ tmp = (tmp*base)%MOD; } return tmp; } LL mod_inv(LL a){ return big_mod(a, MOD-2); } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ cin>>s; int q; fac[1]=1; for(LL i=2; i>q; while(q--){ int l,r; cin>>l>>r; //cout<<(get(r,0)-get(l-1,0))< v; for(int i=0; i<26; i++){ int tmp = get(r,i)-get(l-1,i); if(tmp>0){ v.push_back(tmp); } } LL per_cnt=0; LL odd_count=0; LL mod_inv_calc=1; for(int i=0; i=2){ per_cnt+=(v[i]/2); } if(v[i]%2){ odd_count++; } if(v[i]>=4){ mod_inv_calc= (mod_inv_calc*fac[v[i]/2])%MOD; } } LL ans=0; if(per_cnt>0){ ans=(fac[per_cnt]*mod_inv(mod_inv_calc))%MOD; if(odd_count){ ans=(ans*odd_count)%MOD; } }else{ ans=odd_count; } cout<