import Control.Monad

ok' bit s p = ( length $ [] ++ [　() | si <- s, bit !! (si-1) ] ) `mod` 2 == p
ok bit s p m = ( length $ [] ++ [ () | i <- [0..m - 1], ok' bit (s !! i) (p !! i) ] ) == m

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