import Control.Applicative
import Control.Monad
import Data.List
import Data.Bool (bool)
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V

main :: IO ()
main = do
  xs <- f
  ys <- f
  zs <- f
  n <- readLn
  solve (V.fromList (xs ++ ys ++ zs)) <$> replicateM n readLn >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: Vector Int -> [Int] -> String
solve v xs = bool "No" "Yes" $ vv ! 0 == 0 && vv ! 1 == 0 && vv ! 2 == 0 ||
                               vv ! 3 == 0 && vv ! 4 == 0 && vv ! 5 == 0 ||
                               vv ! 6 == 0 && vv ! 7 == 0 && vv ! 8 == 0 ||
                               vv ! 0 == 0 && vv ! 3 == 0 && vv ! 6 == 0 ||
                               vv ! 1 == 0 && vv ! 4 == 0 && vv ! 7 == 0 ||
                               vv ! 2 == 0 && vv ! 5 == 0 && vv ! 8 == 0 ||
                               vv ! 0 == 0 && vv ! 4 == 0 && vv ! 8 == 0 ||
                               vv ! 2 == 0 && vv ! 4 == 0 && vv ! 6 == 0
  where
    vv = foldl' f v xs
    f t x = case V.findIndex (== x) t of
             Just i -> t // [(i, 0)]
             Nothing -> t
