#include using namespace std; #define x first #define y second #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define pi pair #define pl pair #define pd pair #define ld long double #define pld pair #define lg length() #define sz size() #define pb push_back #define MAXN 100005 #define INF 1000000005 #define LINF 1000000000000000005 #define x1 xdddddddddddddddddd #define y1 ydddddddddddddddddd string s; ll cnt[100005]['z'-'a'+5],t='z'-'a',q,l,r,f,sm,k,fc[100005],mod=1e9+7,ans,inv[100005]; ll pwr(ll a, ll p){ if(p==0) return 1; if(p%2) return (pwr(a,p-1)*a)%mod; ll t=pwr(a,p/2); return (t*t)%mod; } int32_t main(){ ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cin >> s; fc[0]=1; inv[0]=1; for(int i=0;i> q; for(int i=1;i<=q;i++){ cin >> l >> r; sm=0; k=0; ans=1; for(int j=0;j<=t;j++){ f=cnt[r][j]-cnt[l-1][j]; if(f%2) k++,f--; sm+=f; ans*=inv[f/2]; ans%=mod; } if(!k) k++; ans*=fc[sm/2]; ans%=mod; ans*=k; ans%=mod; cout << ans << '\n'; } }