N, M = map(int, input().split())
S = [list(map(int, input().split()))[1::] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
    f = True
    bag = []
    total = 0
    for j in range(0, N):  # このループが一番のポイント
        if (i >> j) & 1:  # 順に右にシフトさせ最下位bitのチェックを行う
            bag.append(j + 1)
    for s in S:
        for ss in s:
            if ss in bag:
                total += 1
        if total % 2 != P[S.index(s)]:
            f = False
    if f:
        ans += 1
print(ans)

