#include <bits/stdc++.h>
using namespace std;

int main()
{
    vector<pair<int, bool>> bingoSheetVec;
    for (int i = 0; i < 9; ++i)
    {
        int input;
        cin >> input;
        bingoSheetVec.push_back(make_pair(input, false));
    }

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int input;
        cin >> input;

        for (int j = 0; j < 9; ++j)
        {
            if (input == bingoSheetVec.at(j).first)
            {
                bingoSheetVec.at(j).second = true;
            }
        }
    }

    // for (int i = 0; i < 9; ++i)
    // {
    //     cout << bingoSheetVec.at(i).first << ": " << bingoSheetVec.at(i).second << endl;
    // }

    bool isBingo = false;

    bool isBingoForSingleLine = false;
    int indexNum = 0;
    for (const auto &singleBingoNum : bingoSheetVec)
    {
        if (singleBingoNum.second)
        {
            if (indexNum % 3 == 0)
            {
                isBingoForSingleLine = true;
            }
        }
        else if (isBingoForSingleLine)
        {
            isBingoForSingleLine = false;
        }

        if ((indexNum - 2) % 3 == 0 && isBingoForSingleLine)
        {
            isBingo = true;
            break;
        }

        ++indexNum;
    }

    if (!isBingo)
    {
        vector<bool> isBingoForSingleRow(3, false);
        int indexNum = 0;
        for (const auto &singleBingoNum : bingoSheetVec)
        {
            if (singleBingoNum.second)
            {
                if (indexNum <= 2)
                {
                    isBingoForSingleRow.at(indexNum) = true;
                }
            }
            else
            {
                isBingoForSingleRow.at(indexNum % 3) = false;
            }

            if (6 <= indexNum)
            {
                if (isBingoForSingleRow.at(indexNum % 3))
                {
                    isBingo = true;
                    break;
                }
            }

            ++indexNum;
        }
    }

    if (!isBingo)
    {
        bool isBingoForRightDown = false, isBingoForLeftDown = false;
        int indexNum = 0;
        for (const auto &singleBingoNum : bingoSheetVec)
        {
            if (singleBingoNum.second)
            {
                if (indexNum == 0)
                {
                    isBingoForRightDown = true;
                }
                else if (indexNum == 2)
                {
                    isBingoForLeftDown = true;
                }

                // cout << "true " << indexNum << endl;
            }
            else
            {
                if (indexNum == 4)
                {
                    isBingoForRightDown = false;
                    isBingoForLeftDown = false;
                }
                else if (indexNum == 6)
                {
                    isBingoForLeftDown = false;
                }
                else if (indexNum == 8)
                {
                    isBingoForRightDown = false;
                }

                // cout << "false " << indexNum << endl;
            }

            if (indexNum == 6 && isBingoForLeftDown)
            {
                isBingo = true;
                break;
            }
            else if (indexNum == 8 && isBingoForRightDown)
            {
                isBingo = true;
                break;
            }

            ++indexNum;
        }
    }

    cout << (isBingo ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256