
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    [n,m] <- r'
    sss <- (map tail <$> replicateM m r') :: IO [[Int]]
    ps <- map (==1) <$> r' :: IO [Bool]
    let bulbAndSwitches = zip ps sss :: [(Bool, [Int])]
    let res = map (\st -> --traceShow st $
                let bulbOn = map (\(p,ss) -> count st ss p) bulbAndSwitches :: [Bool]
                in {-traceShow (bulbOn, and bulbOn) $-} and bulbOn
            ) (onoffV n) :: [Bool]
    print $ length $ filter id res



count :: U.Vector Bool -> [Int] -> Bool -> Bool
count vec iis b = odd (length (filter id $ sublist vec iis)) == b

sublist :: U.Vector Bool -> [Int] -> [Bool]
sublist vec chos = map ((vec U.!) . pred) chos


onoffV :: Int -> [U.Vector Bool]
onoffV m = map U.fromList (onoff m)

onoff :: Int -> [[Bool]]
onoff 0 = [[]]
onoff m = do
    s <- [True,False]
    map (s:) (onoff (m-1))


