local a = {}
local c = {}
for i = 1, 9 do
  a[i] = io.read("*n")
  c[i] = false
end
local n = io.read("*n")
for i = 1, n do
  local b = io.read("*n")
  for j = 1, 9 do
    if a[j] == b then
      c[j] = true
    end
  end
end
local f = false
if c[1] and c[4] and c[7] then f = true end
if c[2] and c[5] and c[8] then f = true end
if c[3] and c[6] and c[9] then f = true end
if c[1] and c[2] and c[3] then f = true end
if c[4] and c[5] and c[6] then f = true end
if c[7] and c[8] and c[9] then f = true end
if c[1] and c[5] and c[9] then f = true end
if c[3] and c[5] and c[7] then f = true end
print(f and "Yes" or "No")
