import Data.List as L
import Control.Monad
ok' :: [Bool] -> [Int] -> Int -> Bool
ok' bit s p = ( length $ [] ++ [　() | si <- s, bit !! (si-1) ] ) `mod` 2 == p

ok :: [Bool] -> [[Int]] -> [Int] -> Int -> Bool
ok bit s p m = ( length $ [] ++ [ () | i <- [0..m - 1], ok' bit (s !! i) (p !! i) ] ) == m

main = do
        [n, m] <- fmap ( L.map read . L.words ) getLine :: IO [Int]
        s <- replicateM m $ fmap ( tail . L.map read . L.words ) getLine :: IO [[Int]]
        p <- fmap ( L.map read . L.words ) getLine :: IO [Int]
        let bits = sequence $ replicate n [False, True]
        print $ length $ [ () | bit <- bits, ok bit s p m ]