import Data.Bits
import Control.Monad

solve :: Int -> [[Int]] -> [Int] -> Int
solve n xss ps = length $ filter id $ map (\b -> step xss ps b) [0..2^n-1]
    where
        step :: [[Int]] -> [Int] -> Int -> Bool
        step [] [] b = True
        step (xs:xss) (p:ps) b = res && (step xss ps b)
            where
                res = (foldl step' 0 $ tail xs) `rem` 2 == p
                step' :: Int -> Int -> Int
                step' acc x
                    | (shiftR b (x-1)) .&. 1 == 1 = acc + 1
                    | otherwise = acc

main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    xss <- replicateM m (map read . words <$> getLine) :: IO [[Int]]
    ps <- map read . words <$> getLine :: IO [Int]
    print $ solve n xss ps