function mark(a_rev, b)
  local marked = {false, false, false,
                  false, false, false,
                  false, false, false}
  for i = 1, #b do
    local bi = b[i]
    if a_rev[bi] then
      marked[a_rev[bi]] = true
    end
  end
  return marked
end

function bingo(marked)
  local bingos = {
    {1, 4, 7}, {2, 5, 8}, {3, 6, 9},
    {1, 2, 3}, {4, 5, 6}, {7, 8, 9},
    {1, 5, 9}, {3, 5, 7}
  }

  for i = 1, 8 do
    local c = bingos[i]
    if marked[c[1]] and marked[c[2]] and marked[c[3]] then
      return true
    end
  end

  return false
end

local a_rev = {}
for i = 1, 9 do
  a = io.read("*n")
  a_rev[a] = i
end

local n = io.read("*n")

local b = {}
for i = 1, n do
  b[i] = io.read("*n")
end

local marked = mark(a_rev, b)
if bingo(marked) then
  print("Yes")
else
  print("No")
end
