#include using namespace std; #define ll long long ll fpower(ll a,ll b, ll M){ ll res=1; while(b){ if(b&1) { res*=a; res%=M; } b>>=1; a*=a; a%=M; } return res; } ll l[100000][26]; int main() { string s; cin >> s; ll M= 1000000007; ll n= s.size(); ll i,j; for(i=0;i> q; for(int a0 = 0; a0 < q; a0++){ ll L; ll r; cin >> L >> r; L-=1; r-=1; ll temp[26]; for(i=0;i<26;i++){ temp[i]= l[r][i]; } if(L){ for(i=0;i<26;i++){ temp[i]-= l[L-1][i]; } } ll cte=0,cto=0; for(i=0;i<26;i++){ if(temp[i]%2){ cto++; cte+=(temp[i]/2); } else cte+=(temp[i]/2); } ll ans = fact[cte]; for(i=0;i<26;i++){ ans = ans * fpower(fact[temp[i]/2],M-2,M); ans%=M; } //cout<