/*
* J1K7_7
*
* You can use my contents on a Creative Commons - Attribution 4.0 International - CC BY 4.0 License. XD
* - JASKAMAL KAINTH
*/
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <cassert>
#include <list>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <limits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
#define left(x) (x << 1)
#define right(x) (x << 1) + 1
#define mid(l, r) ((l + r) >> 1)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(),a.end()
#define debug(x) {cerr <<#x<<" = " <<x<<"\n"; }
#define debug2(x, y) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debug4(x, y, z, w) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<", "<<#w << " = " <<w <<"\n";}
#define ss second
#define ff first
#define m0(x) memset(x,0,sizeof(x))
inline int nextint(){ int x; scanf("%d",&x); return x; }
inline ll nextll() { ll x; scanf("%lld",&x); return x; }
#define gc getchar
template <typename T> void scanint(T &x) {
T c = gc(); while(((c < 48) || (c > 57)) && (c!='-')) c = gc();
bool neg = false; if(c == '-') neg = true; x = 0; for(;c < 48 || c > 57;c=gc());
for(;c > 47 && c < 58;c=gc()) x = (x*10) + (c - 48); if(neg) x = -x;
}
// variadics
template<typename T >T min_ ( T a , T b ) { return a > b ? b : a ; }
template < typename T , typename... Ts > T min_( T first , Ts... last ){ return min_(first, min_(last...)); }
// lambda exp auto square = [](int inp) { return inp * inp; } ;
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
os<<"("<<t.first<<", "<<t.second<<")";
return os;
}
template<typename T> ostream& operator<< (ostream& out, const vector<T>& v) {
out << "["; size_t last = v.size() - 1; for(size_t i = 0; i < v.size(); ++i) {
out << v[i]; if (i != last) out << ", "; } out << "]"; return out;
}
ll pwr(ll base, ll p, ll mod){
ll ans = 1; while(p) { if(p&1) ans=(ans*base)%mod; base=(base*base)%mod; p/=2; } return ans;
}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); }
ll lcm(ll a, ll b) { return a*(b/gcd(a,b)); }
const long double PI = (long double)(3.1415926535897932384626433832795);
const ll mx_ll = numeric_limits<ll> :: max();
const int mx_int = numeric_limits<int> :: max();
const int mod = 1e9+7;
const int oo = 0x3f3f3f3f;
const ll OO = 0x3f3f3f3f3f3f3f3fll;
const int MAXN = 2e5+6;
struct SAAA
{
string s;
int len;
int iSA[MAXN], SA[MAXN];
int cnt[MAXN], next_gen[MAXN], lcp[ MAXN ], LCP[MAXN][22]; //internal
bool bh[MAXN], b2h[MAXN],m_arr[MAXN];
inline void init_SA()
{
for(int i = 0; i < MAXN; i++)
{
iSA[i] = SA[i] = cnt[i] = next_gen[i] = lcp[i] = 0;
bh[i] = b2h[i] = m_arr[i] = 0;
for(int j = 0; j < 22; j++)
LCP[i][j] = 0;
}
}
bool smaller_first_char(int a, int b){
return s[a] < s[b];
}
void SuffixSort(int n) {
for (int i=0; i<n; ++i){
SA[i] = i;
}
vector<pair<char,int> >arrr;
for(int i = 0; i < n; i++)
{
arrr.pb({s[SA[i]],SA[i]});
}
sort(all(arrr));
for(int i = 0; i < n; i++)
{
SA[i] = arrr[i].ss;
}
for (int i=0; i<n; ++i){
bh[i] = i == 0 || s[SA[i]] != s[SA[i-1]];
b2h[i] = false;
}
for (int h = 1; h < n; h <<= 1){
int buckets = 0;
for (int i=0, j; i < n; i = j){
j = i + 1;
while (j < n && !bh[j]) j++;
next_gen[i] = j;
buckets++;
}
if (buckets == n) break;
for (int i = 0; i < n; i = next_gen[i]){
cnt[i] = 0;
for (int j = i; j < next_gen[i]; ++j){
iSA[SA[j]] = i;
}
}
cnt[iSA[n - h]]++;
b2h[iSA[n - h]] = true;
for (int i = 0; i < n; i = next_gen[i]){
for (int j = i; j < next_gen[i]; ++j){
int s = SA[j] - h;
if (s >= 0){
int head = iSA[s];
iSA[s] = head + cnt[head]++;
b2h[iSA[s]] = true;
}
}
for (int j = i; j < next_gen[i]; ++j){
int s = SA[j] - h;
if (s >= 0 && b2h[iSA[s]]){
for (int k = iSA[s]+1; !bh[k] && b2h[k]; k++) b2h[k] = false;
}
}
}
for (int i=0; i<n; ++i){
SA[iSA[i]] = i;
bh[i] |= b2h[i];
}
}
for (int i=0; i<n; ++i){
iSA[SA[i]] = i;
}
}
void InitLCP(int n) {
for (int i=0; i<n; ++i)
iSA[SA[i]] = i;
lcp[0] = 0;
for (int i=0, h=0; i<n; ++i) {
if (iSA[i] > 0) {
int j = SA[iSA[i]-1];
while (i + h < n && j + h < n && s[i+h] == s[j+h])
h++;
lcp[iSA[i]] = h;
if (h > 0)
h--;
}
}
}
void ConstructLCP() {
InitLCP( len );
for(int i = 0;i<len;++i)
LCP[i][0] = lcp[i];
for(int j = 1;(1<<j)<=len;++j){
for(int i = 0;i+(1<<j)-1<len;++i){
if(LCP[i][j-1]<=LCP[i+ ( 1<<(j-1) )][j-1])
LCP[i][j] = LCP[i][j-1];
else
LCP[i][j] = LCP[i+(1<<(j-1))][j-1];
}
}
}
int GetLCP(int x, int y) {
if(x == y) return len-SA[x];
if(x > y) swap(x,y);
int log = 0;
while((1<<log)<=(y-x)) ++log;
--log;
return min(LCP[x+1][log],LCP[y-(1<<log)+1][log]);
}
}str[2];
int main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
string s1, s2;
cin >> s1 >> s2;
string st = s1 + "$" + s2;
str[0].s = st;
str[0].len = st.length();
str[0].init_SA();
str[0].SuffixSort(st.length());
str[0].ConstructLCP();
string c1 = s1;
reverse(all(c1));
string c2 = s2;
reverse(all(c2));
string ts = c1 + "$" + c2;
str[1].s = ts;
str[1].len = ts.length();
str[1].init_SA();
str[1].SuffixSort(ts.length());
str[1].ConstructLCP();
int lens = s1.length();
int lent = s2.length();
int q; cin >> q;
while(q--)
{
int k , a, b , c, d;
cin >> k >> a >> b >> c >> d;
a--,c--,b--,d--;
if((b-a) != (d-c))
{
cout << "NO\n";
continue;
}
int flag = 0;
for(int ik = 0; ik <= k; ik++)
{
if(ik == 0)
{
int lcp1 = str[0].GetLCP(str[0].iSA[a],str[0].iSA[c+lens+1]);
lcp1 = min(lcp1,b-a+1);
if(lcp1 == (b-a+1))
{
flag = 1;
break;
}
}
if(ik == 1)
{
int na = lens - a - 1;
int nb = lens - b - 1;
int nc = lent - c - 1;
int nd = lent - d - 1;
int lcp1 = str[0].GetLCP(str[0].iSA[a],str[0].iSA[c + lens + 1]);
lcp1 = min(lcp1,b-a+1);
int lcp2 = str[1].GetLCP(str[1].iSA[nb],str[1].iSA[nd + lens + 1]);
lcp2 = min(lcp2,d-c+1);
int crap = b-a-lcp1-lcp2+1;
if(crap <= 1)
{
flag = 0;
break;
}
if(crap == 2)
{
if((s1[a+lcp1] == s2[lcp1+c+1]) && (s1[a+lcp1+1] == s2[lcp1+c]))
{
flag = 1;
}
break;
}
}
if(ik == 2)
{
int na = lens - a - 1;
int nb = lens - b - 1;
int nc = lent - c - 1;
int nd = lent - d - 1;
int lcp1 = str[0].GetLCP(str[0].iSA[a],str[0].iSA[c + lens + 1]);
int lcp2 = str[1].GetLCP(str[1].iSA[nb],str[1].iSA[nd + lens + 1]);
char x,y,z;
x = st[a+lcp1];
y = st[a+lcp1+1];
z = st[a+lcp1+2];
char x2,y2,z2;
x2 = st[lens+c+lcp1+1];
y2 = st[lens+c+lcp1+2];
z2 = st[lens+c+lcp1+3];
if((lcp1+lcp2+3) == (b-a+1))
{
if((x2 == y && y2 == z && z2 == x) || (x2 == z && y2 == x && z2 == y))
{
flag = 1;
}
break;
}
int lcp3 = str[0].GetLCP(str[0].iSA[a+lcp1+2],str[0].iSA[lens + c + lcp1 + 3]);
int tem = lcp1 + lcp2 + lcp3 + 3 ;
if(tem == (b-a))
{
if((s1[a+lcp1] == s2[c+lcp1+1]) && (s1[a+lcp1+1] == s2[c+lcp1]))
{
if((s1[a+2+lcp1+lcp3] == s2[c+lcp1+lcp3+3]) && (s1[a+lcp1+3+lcp3] == s2[c+lcp1+lcp3+2]))
{
flag = 1;
break;
}
}
}
else
{
flag = 0;
break;
}
}
}
if(flag)
{
cout << "YES\n";
}
else
{
cout << "NO\n";
}
}
return 0;
}