#include #define ll long long using namespace std; ll l,r,t; string s; ll mas[100001][30]; ll fact[100001]; ll cur[30]; long long binpow (ll a,ll n) { ll res = 1; while (n) { if (n&1) res=(res*a)%1000000007; a=(a*a)%1000000007; n>>=1; } return res; } long long C (int a,int b){ long long k1=1,k2=1,k3=1; k2=(fact[b]*fact[a-b])%1000000007; return (fact[a]*binpow(k2,1000000005))%1000000007; } int n; int main (){ cin>>s; for (int i=0;i<=s.length()-1;i++){ for(int j=0;j<=26;j++){ mas[i+1][j]=mas[i][j]; } mas[i+1][s[i]-'a']++; } fact[0]=1; for (int i=1;i<=100000;i++){ fact[i]=(fact[i-1]*i)%1000000007; } cin>>t; while (t--){ cin>>l>>r; for (int i=0;i<=26;i++){ cur[i]=0; } ll kenti=0; for (int i=0;i<=26;i++){ cur[i]=mas[r][i]-mas[l-1][i]; if (cur[i]%2==1) kenti++; } ll len=0; for (int i=0;i<=26;i++){ cur[i]=cur[i]/2; len+=cur[i]; } long long ans=1; for (int i=0;i<=26;i++){ ans=ans*C(len,cur[i])%1000000007; //cout<