#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! debug {
    ( $x:ident [ $i:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}] = {:?}", stringify!($x), $i, $x[$i]);
        }
    };
    ( $x:ident [ $i:expr ][ $j:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}][{}] = {:?}", stringify!($x), $i, $j, $x[$i][$j]);
        }
    };
    ( $x:expr ) => {
        if cfg!(debug_assertions) {
            println!("{}:{} {} = {:?}", line!(), column!(), stringify!($x), $x);
        }
    };
}

#[allow(unused_must_use)]
fn main() {
    use std::io::{Write, BufWriter};
    let stdin = std::io::stdin();
    let mut stdin = my::io::InputReader::new(stdin.lock());
    let stdout = std::io::stdout();
    let mut stdout = BufWriter::new(stdout.lock());

    let S: String = stdin.read();
    let T: String = stdin.read();
    let S = S.as_bytes();
    let T = T.as_bytes();
    let mut accSA = vec![0; S.len() + 1];
    let mut accSB = vec![0; S.len() + 1];
    let mut accTA = vec![0; T.len() + 1];
    let mut accTB = vec![0; T.len() + 1];
    for i in 0..S.len() {
        accSA[i + 1] = accSA[i] + if S[i] == b'A' { 1 } else { 0 };
        accSB[i + 1] = accSB[i] + if S[i] == b'B' { 1 } else { 0 };
    }
    for i in 0..T.len() {
        accTA[i + 1] = accTA[i] + if T[i] == b'A' { 1 } else { 0 };
        accTB[i + 1] = accTB[i] + if T[i] == b'B' { 1 } else { 0 };
    }
    let q: usize = stdin.read();
    for _ in 0..q {
        let a: usize = stdin.read::<usize>() - 1;
        let b: usize = stdin.read();
        let c: usize = stdin.read::<usize>() - 1;
        let d: usize = stdin.read();
        let countSA = accSA[b] - accSA[a];
        let countSB = accSB[b] - accSB[a];
        let countTA = accTA[d] - accTA[c];
        let countTB = accTB[d] - accTB[c];
        let dS = countSA - countSB;
        let dT = countTA - countTB;
        let result = if (dS - dT) % 3 == 0 { "YES" } else { "NO" };
        stdout.write_fmt(format_args!("{}\n", result));
    }
    stdout.flush();
}

#[allow(dead_code, unused_must_use)]
mod my {
    pub mod io {
        use std::io::{BufRead, ErrorKind, Result};
        use std::str::{FromStr, from_utf8};
        use std::fmt::Debug;

        pub fn read_word<R: BufRead>(r: &mut R, buf: &mut Vec<u8>)
                                              -> Result<usize> {
            let mut read = 0;
            loop {
                let (done, used) = {
                    let available = match r.fill_buf() {
                        Ok(n) => n,
                        Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
                        Err(e) => return Err(e)
                    };
                    match available.iter().position(|&x| x == b'\n' || x == b' ') {
                        Some(i) => {
                            buf.extend_from_slice(&available[..i]);
                            (true, i + 1)
                        }
                        None => {
                            buf.extend_from_slice(available);
                            (false, available.len())
                        }
                    }
                };
                r.consume(used);
                read += used;
                if done || used == 0 {
                    return Ok(read);
                }
            }
        }

        pub struct InputReader<R: BufRead> {
            reader: R,
            buf: Vec<u8>,
        }

        impl<R: BufRead> InputReader<R> {
            pub fn new(reader: R) -> InputReader<R> {
                InputReader {
                    reader: reader,
                    buf: Vec::<u8>::new(),
                }
            }

            pub fn read_word(&mut self) {
                read_word(&mut self.reader, &mut self.buf);
            }
            
            pub fn read<T>(&mut self) -> T
                where T: FromStr,
                      T::Err: Debug
            {
                self.buf.clear();
                self.read_word();
                from_utf8(&self.buf).unwrap().trim().parse().unwrap()
            }
        }
    }
}

Measured memory_bytes: 6652