n,m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
ans = 0

for i in range(m):
    s[i].pop(0)

#print(s)
for i in range(2**n):
    tmp = [False] * m
    for j in range(m):
        if (i>>j) & 1:
            for k in range(m):
                if (j+1) in s[k]:
                    tmp[k] = not tmp[k]
    #print(tmp,p)
    if tmp == p:
        ans += 1
print(ans)