#include using namespace std; int countt[30][30]; void initialize(string s) { // This function is called once before all queries. for (int i=0;i<30;i++) for (int j=0;j<30;j++) countt[i][j]=0; for (int i=0;i<30;i++){ if (i==(s[0]-'a')){ countt[i][0]=1; } } for (int i=1;ii-1;j--){ int countOdd=0; for (int k=0;k<30;k++){ int sum=0; if (i==0) sum=countt[k][j]; else sum=countt[k][j]-countt[k][i-1]; if (sum%2==1) countOdd++; if (countOdd>=2) break; } if (countOdd==1 || countOdd ==0){ if (countOdd==1) return 2; return 1; } } } } 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); cout << result << endl; } return 0; }