#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl '\n' #define ff first #define ss second #define READ freopen("input.txt","r",stdin); #define WRITE freopen("output.txt","w",stdout); #define fill(a,x) memset(a,x,sizeof(a)); #define loop(i,x,n) for(int i=x;i>ttwea;while(ttwea--) #define ll long long #define mod 1000000007 #define vi vector #define pb push_back #define mp make_pair #define int long long #define all(a) a.begin(), a.end() #define ull unsigned long long #define N 8000010 #define inf 10000000000000000 #define debug1(x) cerr << #x << ": " << x <<'\n' #define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n' #define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n' using namespace std; //ll dx[]={1,0,-1,0};ll dy[]={0,1,0,-1}; //4 Direction //ll dx[]={1,1,0,-1,-1,-1,0,1};ll dy[]={0,1,1,1,0,-1,-1,-1};//8 direction ll gcd(ll x,ll y) { if(y==0) return x; else return gcd(y,x%y); } ll expo(ll n,ll m,ll p) //MODULAR EXPONENTIATION { ll r=1; n=n%p; while(m>0) { if(m%2) r=(r*n)%p; n=(n*n)%p; m=m/2; } return r%p; } int fac[200000]; int32_t main() { IOS; /*#ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif /********************* Code starts here ************************/ fac[0]=1; fac[1]=1; for(int i=2;i<=100000;i++) { fac[i]=(fac[i-1]*i)%mod; } string s; cin>>s; int q; cin>>q; int f[26][s.size()+1]; for(int i=0;i<26;i++) { for(int j=0;j<=s.size();j++) { f[i][j]=0; } } for(int i=0;i>l>>r; int F[26]={0}; for(int i=0;i<26;i++) { F[i]=f[i][r]-f[i][l-1]; //cout<