#include <bits/stdc++.h>
using namespace std;
int main() {
int q,l,r,a,b,c,d;
string S,T;
cin>>q>>S>>T;
for(int i=0;i<q;i++){
cin>>l>>r;
a=r-l+1-T.size()+1;
b=0;
for(int j=0;j<a;j++){
if(S[j+l-1]==T[0]){
c=0;
d=T.size();
for(int k=1;k<d;k++){
if(S[j+k+l-1]!=T[k]){
c=1;
}
}
if(c==0){
b=1;
}
}
}
if(b==1){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: