#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2  # type: int


def main():
    N, M = map(int, input().split())
    K = []
    S = []
    for _ in range(M):
        kk, *rest = map(int, input().split())
        K.append(kk)
        S.append(rest)
    P = list(map(int, input().split()))
    # print(N, M)
    # print(K, S, P)

    base = [1]
    for i in range(10):
        base.append(base[-1]*2)
    base = reversed(base)

    counter = 0
    for n in range(1, 2**N):    # 全探索
        flag = True
        # print("{0:04b}".format(n))
        for k, s, p in zip(K, S, P):
            # print(k, s, p)
            sumof = 0
            for ss in s:
                sumof += (n >> (ss-1)) % 2
            sumof %= 2
            if sumof != p:
                flag = False
                break
        if flag:
            counter += 1
    print(counter)


if __name__ == '__main__':
    main()
