Problem:
Score : 200 points

Problem Statement

We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.

The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.

Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.

Constraints

All values in input are integers.

1 \leq A_{i, j} \leq 100

A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))

1 \leq N \leq 10

1 \leq b_i \leq 100

b_i \neq b_j (i \neq j)

Input

Input is given from Standard Input in the following format:

A_{1, 1} A_{1, 2} A_{1, 3}
A_{2, 1} A_{2, 2} A_{2, 3}
A_{3, 1} A_{3, 2} A_{3, 3}
N
b_1
\vdots
b_N

Output

If we will have a bingo, print Yes; otherwise, print No.

Sample Input 1

84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30

Sample Output 1

Yes

We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.

Sample Input 2

41 7 46
26 89 2
78 92 8
5
6
45
16
57
17

Sample Output 2

No

We will mark nothing.

Sample Input 3

60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34

Sample Output 3

Yes

We will mark all the squares.

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)


using System;
using System.Collections.Generic;

namespace Atcorder
{
    class Program
    {
        
        static void Main(string[] args)
        {
            string m = "";
            string[] c = new string[] { m };
            int W = 0;
            int O = 1;
            int X = 0;
            string[] input1= Console.ReadLine().Split(' ');
            int a1 =0;
            int a2=0;
            int a3=0;

            string[] input2 = Console.ReadLine().Split(' ');
            int b1=0;
            int b2=0;
            int b3=0;

            string[] input3 = Console.ReadLine().Split(' ');
            int c1=0;
            int c2=0;
            int c3=0;

            int N = int.Parse(Console.ReadLine());

            for(int i = 0; i < 0; i++)
            {
                c = new string[] { m , Console.ReadLine() };
                m = string.Join(" ",c);
            }

            var list = new List<string>();
            list.AddRange(c);
            string itema1 = a1.ToString();

            if (list.Contains(itema1))
            {
                a1 = O;
            }
            else
            {
                a1 = X;
            }

            string itema2 = a2.ToString();

            if (list.Contains(itema2))
            {
                a2 = O;
            }
            else
            {
                a2 = X;
            }
            string itema3 = a3.ToString();

            if (list.Contains(itema3))
            {
                a3 = O;
            }
            else
            {
                a3 = X;
            }

            string itemb1 = b1.ToString();

            if (list.Contains(itemb1))
            {
                b1 = O;
            }
            else
            {
                b1 = X;
            }
            
            string itemb2 = b2.ToString();

            if (list.Contains(itemb2))
            {
                b2 = O;
            }
            else
            {
                b2 = X;
            }

            string itemb3 = b3.ToString();

            if (list.Contains(itemb3))
            {
                b3 = O;
            }
            else
            {
                b3= X;
            }

            string itemc1 = c1.ToString();

            if (list.Contains(itemc1))
            {
                c1 = O;
            }
            else
            {
                c1 = X;
            }

            string itemc2 = c2.ToString();

            if (list.Contains(itemc2))
            {
                c2 = O;
            }
            else
            {
                c2 = X;
            }

            string itemc3 = c3.ToString();

            if (list.Contains(itemc3))
            {
                c3 = O;
            }
            else
            {
                c3 = X;
            }

            if ((1 == a1) && (1 == a2) && (1 == a3))
            {
                W++;
            }
            if ((1 == b1) && (1 == b2) && (1 == b3))
            {
                W++;
            }
            if ((1 == c1) && (1 == c2) && (1 == c3))
            {
                W++;
            }
            if ((1 == a1) && (1 == b2) && (1 == c3))
            {
                W++;
            }
            if ((1 == a3) && (1 == b2) && (1 == c1))
            {
                W++;
            }
            if ((1 == a1) && (1 == b1) && (1 == c1))
            {
                W++;
            }
            if ((1 == a2) && (1 == b2) && (1 == c2))
            {
                W++;
            }
            if ((1 == a3) && (1 == b3) && (1 == c3))
            {
                W++;
            }


            if (W > 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}