#include #define ll long long ll mod = 1000000007; using namespace std; ll fac[100005]; void createFactorial(){ fac[0] = 1; for(int i=1;i<100004;++i){ fac[i] = (fac[i-1]*i)%mod; } } ll fastPow(ll a , ll b){ if(!b) return 1; ll x = fastPow(a , b/2); x = (x*x)%mod; if(b%2) x=(x*a)%mod; return x; } ll solve(int arr[]){ ll x = 0 , y = 0 , ans = 1 , div = 1; for(int i=0;i<26;++i){ div = (fac[arr[i]/2]*div)%mod; y += (arr[i]/2); x += (arr[i]%2); } ans = ((fac[y] * fastPow(div , mod-2))%mod )%mod; if(x) return (ans*x)%mod; return ans; } int main(){ string s; cin >> s; int n = s.size(); int arr[n][26]; createFactorial(); for(int i=0;i<26;++i){ if(s[i] == 'a'+i) arr[0][i] = 1; else arr[0][i] = 0; } for(int i=1;i> q; while(q--){ int l , r; cin >> l >> r; --l , --r; int temp[26]; for(int i=0;i<26;++i) temp[i] = arr[r][i] - arr[l][i]; ++temp[s[l]-'a']; //for(int i=0;i<26;++i) cout << temp[i] << " "; //cout << endl; cout << solve(temp) << endl; } }