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


res = 0
for i in range(2**n):
    on = [0 for _ in range(n)]
    for j in range(n):
        if((i>>j)&1):
            on[j]=1
    all_on = True 
    for j in range(m):
        on_num = 0 
        for s in ks[j][1: ]:
            if(on[s-1]): on_num += 1 

        if(on_num%2 != p[j]):
            break 

    if(all_on): res += 1
print(res)