import io.StdIn.{readLine, readInt}
object Main extends App {
  val s = readLine
  val t = readLine
  val q = readInt
  val abcds = Seq.fill(q)(readLine.split(" ").toSeq.map(_.toInt))

  for (Seq(a, b, c, d) <- abcds) {
    val sab = s.slice(a - 1, b)
    val tcd = t.slice(c - 1, d)
    println(if (canTransform(sab, tcd)) "YES" else "NO")
  }

  def canTransform(s: String, t: String) = helper(s) == helper(t)
  def helper(st: String) = st.map(_ - 'A' + 1).sum % 3
}
