import Control.Monad
import Data.List

solveSub [] ts [] = True
solveSub (bs:bss) ts (p:ps)
    | mod (sum (zipWith (*) bs ts)) 2 == p = solveSub bss ts ps
    | otherwise = False

solve bss [] ps = 0
solve bss (ts:tss) ps
    | solveSub bss ts ps = 1 + solve bss tss ps
    | otherwise = solve bss tss ps

main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    kss <- replicateM m (sort.tail.map read . words <$> getLine) :: IO [[Int]]
    ps <- map read . words <$> getLine :: IO [Int]
    let bss = map (\ks -> map (\x-> if elem x ks then 1 else 0 ) [1..n]) kss
    let tss = replicateM n [0,1]
    print $ solve bss tss ps
