#include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; int main(){ string s ; cin >>s; int m; cin >>m; vector<int> l(m),r(m); for(int i = 0 ; i < m ; ++ i ) cin >> l[i]>>r[i]; int n = s.length(); vector<int> x(n+1,0),y(n+1,0),z(n+1,0); for(int i = 0; i < n; ++ i){ x[i+1] =x[i]; y[i+1] = y[i]; z[i+1] = z[i]; if(s[i] == 'x') x[i+1]++; else if(s[i] == 'y') y[i+1]++; else z[i+1]++; } for(int i = 0 ; i < m ; ++ i){ if(r[i]-l[i]+1 < 3) cout<<"YES"<<endl; else{ vector<int> num(3,0); num[0] = x[r[i]]-x[l[i]-1]; num[1] = y[r[i]]-y[l[i]-1]; num[2] = z[r[i]]-z[l[i]-1]; sort(num.begin(),num.end()); if((num[0] == num[1] && num[1] == num[2])|| (num[2]-num[1] == 1 && num[1] == num[0]) || (num[2]-num[1] == 0 && num[1] - num[0] == 1)) cout<<"YES"<<endl; else cout<<"NO"<<endl; } } return 0; }