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
f = fmap (map read . words) getLine

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