{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Char8 as B
import Data.Attoparsec.ByteString.Char8

type Input  = (Int, Int, Int, [Int], [[Int]])
type Output = Int

input :: Parser Input
input = do
  (_N, _M, _C) <- decimalTriple
  _Bs <- decimalList
  _Ass <- count _N decimalList
  return (_N, _M, _C, _Bs, _Ass)

decimalTriple :: Parser (Int, Int, Int)
decimalTriple = (,,)
  <$> signed decimal <* char ' '
  <*> signed decimal <* char ' '
  <*> signed decimal <* endOfLine

decimalList :: Parser [Int]
decimalList = signed decimal `sepBy` char ' ' <* endOfLine

main :: IO ()
main = B.interact
  $ B.pack . show . either (error "parse err") solve . parseOnly input

solve :: Input -> Output
solve (_N, _M, _C, _Bs, _Ass) =
  length [ _As | _As <- _Ass, inner _As _Bs + _C > 0 ]

inner :: [Int] -> [Int] -> Int
inner xs ys = sum $ zipWith (*) xs ys