//---------- begin scannner ----------
#[allow(dead_code)]
mod scanner {
    use std;
    use std::io::Read;
    use std::str::FromStr;
    use std::str::SplitWhitespace;
    pub struct Scanner<'a> {
        it: SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a String) -> Scanner<'a> {
            Scanner {
                it: s.split_whitespace(),
            }
        }
        pub fn next<T: FromStr>(&mut self) -> T {
            match self.it.next().unwrap().parse::<T>() {
                Ok(v) => v,
                _ => panic!("Scanner error"),
            }
        }
        pub fn next_chars(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}
//---------- end scannner ----------

use std::io::Write;

fn main() {
    let sc = scanner::read_string();
    let sc = scanner::Scanner::new(&sc);
    let out = std::io::stdout();
    let out = std::io::BufWriter::new(out.lock());
    run(sc, out);
}

fn run(mut sc: scanner::Scanner, mut out: std::io::BufWriter<std::io::StdoutLock>) {
    let mut mino = vec![];
    for _ in 0..4 {
        let h: usize = sc.next();
        let w: usize = sc.next();
        let mut b = 0u64;
        for i in 0..h {
            let s = sc.next_chars();
            for j in 0..w {
                if s[j] == '#' {
                    b |= 1u64 << (i * 10 + j) as u64;
                }
            }
        }
        mino.push((h, w, b));
    }
    let mut board = vec![];
    for i in 0..4 {
        let mut a = vec![];
        for j in 0..4 {
            if i == j {
                continue;
            }
            a.push(mino[j]);
        }
        for i in 0..40 {
            let (h, w, b) = a[0];
            let (x, y) = (i / 10, i % 10);
            if x + h > 4 || y + w > 10 {
                continue;
            }
            let bit = b << i;
            for j in 0..40 {
                let (h, w, b) = a[1];
                let (x, y) = (j / 10, j % 10);
                if x + h > 4 || y + w > 10 {
                    continue;
                }
                if (bit >> j) & b > 0 {
                    continue;
                }
                let bit = bit | (b << j);
                for k in 0..40 {
                    let (h, w, b) = a[2];
                    let (x, y) = (k / 10, k % 10);
                    if x + h > 4 || y + w > 10 {
                        continue;
                    }
                    if (bit >> k) & b > 0 {
                        continue;
                    }
                    let bit = bit | (b << k);
                    board.push(bit);
                }
            }
        }
    }
    board.sort();
    board.dedup();
    let n: usize = sc.next();
    for _ in 0..n {
        let mut b = 0;
        for i in 0..4 {
            let s = sc.next_chars();
            for j in 0..10 {
                if s[j] == '.' {
                    b |= 1u64 << (10 * i + j);
                }
            }
        }
        let ans = if let Ok(_) = board.binary_search(&b) {
            "Yes"
        } else {
            "No"
        };
        writeln!(out, "{}", ans).unwrap();
    }
}



Measured memory_bytes: 10248