[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let checkOne (ss, p) (ary: int []) =
    List.map (fun i -> ary.[i - 1]) ss
    |> List.sum
    |> fun x -> x % 2
    |> fun x -> x = p

let checkAll xs ary =
    List.forall (fun x -> checkOne x ary) xs

[<EntryPoint>]
let main _ =
    let [n;m] = reads int
    let kss = List.map (fun _ -> reads int |> List.tail) [1..m]
    let ps = reads int
    let qs = List.zip kss ps

    let t = [| for i = 1 to 10 do yield pown 2 i - 1 |]
    [
        for i = 0 to t.[n - 1] do
            yield
                [|
                    for j = 0 to n - 1 do
                        yield ((i >>> j) &&& 1)
                |]
    ]
    |> List.map (checkAll qs)
    |> List.filter id
    |> List.length
    |> printfn "%i"
    0