// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30"# => r#"Yes"#,

r#"41 7 46
26 89 2
78 92 8
5
6
45
16
57
17"# => r#"No"#,

r#"60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34"# => r#"Yes"#

}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        a: [(usize, usize, usize); 3],
        n: usize,
        b: [usize; n],
    }

    let mut bingo = vec![vec![false; 3]; 3];

    for i in 0..n {
        for j in 0..3 {
            if b[i] == a[j].0 {
                bingo[j][0] = true;
            }

            if b[i] == a[j].1 {
                bingo[j][1] = true;
            }

            if b[i] == a[j].2 {
                bingo[j][2] = true;
            }
        }
    }

    if (0..3).into_iter().all(|i| bingo[0][i]) ||
       (0..3).into_iter().all(|i| bingo[1][i]) ||
       (0..3).into_iter().all(|i| bingo[2][i]) ||

       (0..3).into_iter().all(|i| bingo[i][0]) ||
       (0..3).into_iter().all(|i| bingo[i][1]) ||
       (0..3).into_iter().all(|i| bingo[i][2]) ||

       (bingo[0][0] && bingo[1][1] && bingo[2][2]) ||
       (bingo[0][2] && bingo[1][1] && bingo[2][0]) {
         "Yes"
     } else {
         "No"
     }.to_string()
}

Measured memory_bytes: 4352