fun main(args: Array<String>) {
    val partS = partSum(readLine()!!)
    val partT = partSum(readLine()!!)
    val q = readLine()!!.toInt()
    for (i in 1..q) {
        val (a, b, c, d) = readLine()!!.split(' ').map(String::toInt)
        println(if (modd(partS, a, b) == modd(partT, c, d)) "YES" else "NO")
    }
}

fun modd(z: IntArray, a: Int, b: Int): Int {
    return (z[b] - z[a - 1] + b - a) % 3
}

fun partSum(s: String): IntArray {
    val res = IntArray(s.length + 1)
    for ((i, c) in s.withIndex()) {
        res[i + 1] = res[i] + (if (c == 'A') 1 else 0)
    }
    return res
}
