#include <bits/stdc++.h>   using namespace std;   char str[100010];   int ct[100010][4];   int main() {     int N, x[5], R, L, M;     scanf( %s , str);     N = strlen(str);     for (int i = 1; i <= N; i++) {       for (int j = 0; j < 3; j++) ct[i][j] = ct[i - 1][j];       ct[i][str[i - 1] -  x ]++;     }     scanf( %d , &M);     for (int i = 0; i < M; i++) {       scanf( %d%d , &L, &R);       L--;       if (R - L < 3) {         puts( YES );         continue;       }       for (int j = 0; j < 3; j++) x[j] = ct[R][j] - ct[L][j];       if (x[0] <= x[1] && x[1] <= x[2] && x[2] - x[0] <= 1)         puts( YES );       else if (x[1] <= x[2] && x[2] <= x[0] && x[0] - x[1] <= 1)         puts( YES );       else if (x[2] <= x[0] && x[0] <= x[1] && x[1] - x[2] <= 1)         puts( YES );       else         puts( NO );     }     return 0;   }   