#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N, M = [int(x) for x in input().split()]

S =[]
for j in range (M):
    a = [x for x in input().split()]
    k = a[0]
    s = [int(x) for x in a[1:]]
    S.append(s)
P = [int(x) for x in input().split()]
ans = 0
for i in range (2**N):
    n = format(i,'b').zfill(N)
    
    count = 0
    for j in range (M):
        count2 = 0
        for k in range (len(S[j])):
            count2 += int(n[S[j][k]-1])
        if count2 %2 == P[j]:
            count += 1
    if count == M:
        ans += 1

print(ans)
        



 
    




