/*** Author: ShivamRathore (Shivam010) Problem: String Sets ***/ #include //#include using namespace std; #define ll long long #define mk make_pair #define pb push_back #define Pi pair #define Pl pair #define vi vector #define vl vector #define vb vector #define vp vector > #define vpl vector > #define F first #define S second const ll mod=1000000007; ll po(ll a,ll b,ll m){ ll p=a,ans=1; while(b){ if(b&1){ ans=(ans*p)%m; } p=(p*p)%m; b>>=1; } return ans; } int main() { vl fact(100001); fact[0]=1; for(int i=1;i<100001;i++){ fact[i]=(fact[i-1]*i)%mod; } string s; cin >> s; ll n=s.size(); ll cnt[n+1][26]; for(int i=0;i<=n;i++){ for(int j=0;j<26;j++) cnt[i][j]=0; } for(int i=1;i<=n;i++){ cnt[i][s[i-1]-'a']=1; for(int j=0;j<26;j++){ cnt[i][j]=(cnt[i][j]+cnt[i-1][j])%mod; //cout<> q; for(int a0 = 0; a0 < q; a0++){ int l; int r; cin >> l >> r; ll ans=0,x=0,y=1; ll c; for(int i=0;i<26;i++){ c=(cnt[r][i]-cnt[l-1][i]+mod)%mod; //cout<1){ y=(1LL*y*po(fact[c/2],mod-2,mod))%mod; x+=(c/2); } } x=(fact[x]*y)%mod; if(ans>1) x=(x*ans)%mod; cout<