n, m = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
count = 0
for i in range(n**2):
    switch = [0]*n
    for j in range(n):
        if ((i >> j) & 1):
            switch[j] = 1
    for k in range(m):
        on = 0
        All = True
        for l in range(len(lis[k][1:])):
            on += switch[lis[k][1+l]-1]
        if on % 2 == p[k]:
            continue
        else:
            All = False
            break
    if All == True:
        count += 1
        
print(count)