func_code_string: #include<iostream>   #include<string>   using namespace std;   int main() {    int T;    cin >> T;    for (int t=0;t<T;t++) {     string s;     int n, q;     cin >> n >> q >> s;     int f0 = -1;     int f1 = -1;     int l0 = -1;     int l1 = -1;     for (int i=0;i<n;i++) {      if(s[i]== 0 ) {       l0=i;        if( f0==-1) {        f0=i;       }      } else if(s[i]== 1 ) {       l1=i;       if(f1==-1) {        f1=i;       }      }     }     for(int i=0;i<q;i++) {      int l, r;      cin >> l >> r;      l--;      r--;      bool extendLeft = (s[l]== 0  && f0 < l) || (s[l]== 1  && f1 < l);      bool extendRight = (s[r]== 0  && l0 > r) || (s[r]== 1  && l1 > r);      if(extendRight || extendLeft) {       cout <<  YES  << endl;      } else {       cout <<  NO  << endl;      }     }    }   }   