import java.util.*

private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

private inline fun <T, R> Collection<T>.scanIndexed(initial: R, operation: (Int, R, T) -> R): List<R> {
    val result = ArrayList<R>(size)
    var prevResult = initial
    forEachIndexed { index, element ->
        val elementResult = operation(index, prevResult, element)
        result.add(elementResult)
        prevResult = elementResult
    }
    return result
}

private inline fun <T, R> Collection<T>.scan(initial: R, operation: (R, T) -> R): List<R>
        = scanIndexed(initial) {i, list, elem -> operation(list, elem) }

private fun String.toModCumulative() = toList().scan(0) { cum, char ->
    cum + if(char == 'A') 1 else 2
}

fun main(args: Array<String>) {
    val S = readLine()!!
    val T = readLine()!!
    val q = readInts()[0]
    val queries = (0 until q).map { readInts() }

    val sCumulative = listOf(0) + S.toModCumulative()
    val tCumulative = listOf(0) + T.toModCumulative()

    queries.forEach {
        val (a, b, c, d) = it
        val sMod = sCumulative[b] - sCumulative[a - 1]
        val tMod = tCumulative[d] - tCumulative[c - 1]
        println(if(sMod % 3 == tMod % 3) "YES" else "NO")
    }
}