#include #include #include #include #include using namespace std; typedef long long int ll; void fact(ll y[]) { y[0]=1; for(ll a=1;a<27;a++) { y[a]=y[a-1]*a; } } ll fact1(ll a) { ll b=1; for(ll c=a;c>=1;c--) { b*=c; } return b; } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ string s; cin>>s; ll q=0; cin>>q; while(q--) { ll l=0,r=0; cin>>l>>r; ll x[26]={0}; ll y[27]={0}; fact(y); for(ll a=l-1;a0 && x[a]%2==0) { count+=x[a]; } else if(x[a]) { if(x[a]==max1) { d++; } else { d=1; } max1=max(x[a],max1); } } count+=max1; count/=2; ll c=fact1(count); cout<