n,m = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))

ans = 0
on_off = [0]*n
checker = [0]*m
for i in range(2**n-1):
    for j in range(n):
        if on_off[j] == 1:
            on_off[j] = 0
        else:
            on_off[j] = 1
            break
    slider = [1]*m
    for j in range(m):
        checker[j] = p[j]
    for j in range(1,n+1):
        for k in range(m):
            for l in range(1,ks[k][0]+1):
                if ks[k][l] == j and on_off[j-1] == 1:
                        checker[k] = 1 - checker[k]
    for j in range(m):
        if checker[j] == 1:
            break
        elif j == m-1:
            ans += 1

print(ans)
