type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f1 f2 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1]))
  member this.Scan3 f1 f2 f3 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1], f3 a.[2]))
  member this.Scan4 f1 f2 f3 f4 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1], f3 a.[2], f4 a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [ for i in 1..n -> stream.ReadLine().ToCharArray() ]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let N,M = util.Scan2 int int
let xs = util.ScanMatrix M int
let ps = util.ScanVecH int

// i番目の電球は状態nでついているか
let isON n i =
  let arr = Array.skip 1 xs.[i] // 最初のデータは要素数なので無視
  let count = arr |> Array.sumBy (fun j -> (n >>> (j-1)) &&& 1)
  (count + ps.[i]) % 2 = 0

[0..(pown 2 N)-1]
|> List.filter (fun n -> [0..M-1] |> List.forall (isON n))
|> List.length
|> printfn "%d"
