local A = {}
for i = 1, 3 do
   A[i] = {}
   for j = 1, 3 do        
        A[i][j] = io.read("*n")
   end
end
local A_bool = {}
for i = 1, 3 do
    A_bool[i] = {}
    for j = 1, 3 do        
        A_bool[i][j] = false
    end
end
local N = io.read("*n")
for i = 1, N do
    for j = 1, 3 do
        for k = 1, 3 do
            if A[j][k] == b[i] then
                A_bool[j][k] = true
        end
    end
end

local result = "No"
for i = 1, 3 do
    if A_bool[0][i] and A_bool[1][i] and A_bool[2][i] then
        result = "Yes"
    end
end
for i = 1, 3 do
    if A_bool[i][0] and A_bool[i][1] and A_bool[i][2] then
        result = "Yes"
    end
end
if A_bool[0][0] and A_bool[1][1] and A_bool[2][2] result = "Yes"
if A_bool[0][2] and A_bool[1][1] and A_bool[2][0] result = "Yes"

print(result)