import Control.Applicative
import Data.List
import Control.Monad

getLineN n = replicateM n getLine
listToTuple [a,b] = (a,b)

main = do
	[n,m] <- map read.words <$> getLine :: IO [Int]
	xs' <- map (tail.map read.words) <$> getLineN m :: IO [[Int]]
	ps <- map read.words <$> getLine :: IO [Int]
	let xs = zip  xs' ps
	putStrLn.show $ foldl (answer xs) 0 [1..(2^n-1)]

answer :: [([Int],Int)] -> Int -> Int -> Int
answer xs cnt v = if satisfied xs then cnt+1 else cnt  where
	satisfied = all (judge (bin v))

bin 0 = replicate 10 0
bin k = mod k 2 : bin (div k 2)

judge binary (sws,p) = sum  extracted `mod` 2 == p where
		extracted = map (\i -> binary !! (i-1)) sws