#include using namespace std; typedef long long ll; typedef long double ld; const int N=1e5+10; const ll mod=1000000007; ll powmod(ll a1,ll b1,ll modx) {ll res=1; a1%=modx; for(;b1;b1>>=1) {if(b1&1)res=res*a1%modx; a1=(a1*a1)%modx;}return res;} ll inv(ll ax,ll modx) { return powmod(ax,modx-2,modx); } int a[N][26]; ll fact[N],invfact[N]; int main(){ //freopen("a.txt", "r", stdin); //freopen("answers.txt", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); string s; cin>>s; int n=s.length(); for(int i=0;i>q; while(q--){ int l,r; cin>>l>>r; l--; r--; int odd=0; int even=0; vector ed; for(int i=0;i<26;i++){ int foo; if(l!=0) foo=a[r][i]-a[l-1][i]; else foo=a[r][i]; if(foo%2!=0){ int xx=foo/2; even+=xx; ed.push_back(xx); odd++; } else{ even+=foo/2; ed.push_back(foo/2); } } ll ans=fact[even]; if(odd!=0) ans*=odd; ans%=mod; for(int it:ed){ ans*=invfact[it]; ans%=mod; } cout<