n,m = map(int,input().split())
import copy
k = [0 for i in range(m)]
ans = 0
import copy
for i in range(m):
    k[i] = list(map(int,input().split()))
p = list(map(int,input().split()))
for i in range(2**n):
    v = 1
    u = 0
    d = [0 for i in range(n)]
    q = copy.deepcopy(i)
    for j in range(n):
        if q &1:
            d[j] = 1
        q = q >> 1
    for g in range(m):
        for c in range(1,k[g][0]+1):
            u += d[k[g][c]-1]
        if u%2 == p[g]:
            continue
        else:
            v = 0
            break
    if v:
        ans += 1
print(ans)