from sys import stdin
from itertools import combinations_with_replacement

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
p = list(map(int,stdin.readline().rstrip().split()))

hai = [0,1]
hai = list(combinations_with_replacement(hai, n))
point = 0

for i in range(len(hai)):
    h = list(hai[i])
    kai = 0
    for j in range(m):
        gou = 0
        for k in range(1,len(li[j])):
            if h[li[j][k]-1] == 1:
                gou += 1
        if p[j] != gou%2:
            kai += 1
    if kai == 0:
        point += 1
print(point)