#include #define ll long long using namespace std; //void initialize(string s) { // This function is called once before all queries. //} int answerQuery(int l, int r ,string s) { map m; for(int i=l;i<=r;i++) m[s[i]]+=1; int count=0,flag=0; map::iterator it; for(it=m.begin();it!=m.end();it++) { if((it->second)%2==0) { count+=1; it->second=0; } if((it->second)%2==1) { if(it->second > 1) count+=1; flag=1; it->second=0; } } if(flag==1) count+=1; m.clear(); return count%1000000007; // Return the answer for this query modulo 1000000007. } int main() { string s; cin >> s; // initialize(s); int q; cin >> q; for(int a0 = 0; a0 < q; a0++){ int l; int r; cin >> l >> r; int result = answerQuery(l, r,s); cout << result << endl; } return 0; }