n,m = map(int,input().split())
x = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
ans = 0
for i in range(2 ** n):
    bag = [0]*n
    res = 0
    cnt = 0
    for j in range(n):  
        if ((i >> j) & 1):  
            bag[j]+=1
    for l in range(m):
        for h in range(1,len(x[l])):
            res += bag[x[l][h]-1]
        if res%2!=p[l]:
            break
        else:
            cnt += 1
    if cnt==m:
        ans += 1
print(ans)
        
