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

c = 0
for i in range(2**n):
    t = format(i,"010b")
    s = t[10-n:]
    q = 0
    r = 0
    for j in range(m):
        for u in range(k[j][0]):
            q += int(s[k[j][u+1]-1])
        if q % 2 == p[j]:
            continue
        else:
            r = 1
            break
    if r == 0:
        c += 1

print(c)