import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  string t; readV(t);

  auto sf = s.map!(si => si == 'A' ? 1 : 2).array;
  auto tf = t.map!(ti => ti == 'A' ? 1 : 2).array;

  auto sc = sf.cumulativeSum;
  auto tc = tf.cumulativeSum;

  int q; readV(q);
  foreach (_; 0..q) {
    int a, b, c, d; readV(a, b, c, d); --a; --c;
    writeln(sc[a..b]%3 == tc[c..d]%3 ? "YES" : "NO");
  }
}

class CumulativeSum(T)
{
  size_t n;
  T[] s;

  this(T[] a)
  {
    n = a.length;
    s = new T[](n+1);
    s[0] = T(0);
    foreach (i; 0..n) s[i+1] = s[i] + a[i];
  }

  T opSlice(size_t l, size_t r) { return s[r]-s[l]; }
  size_t opDollar() { return n; }
}
auto cumulativeSum(T)(T[] a) { return new CumulativeSum!T(a); }
