k = []

n, m = map(int, input().split())
for i in range(m):
    k.append(list(map(int, input().split())))
    del k[i][0] 

p = list(map(int, input().split()))

cnt = 0
ans = 0
for i in range(2 ** n):
    lis = [False] * n

    for j in range(n):
        if (i >> j) & 1:
            lis[j] = True
    print(lis)
    cnt = 0
    for j in range(m):
        val = 0
        for l in range(len(k[j])):
            if lis[k[j][l]-1] == True:
                val += 1
            #print(lis[k[j][l]-1])
        if val % 2 == p[j]:
            cnt += 1
        #print(val)
        #print(cnt)
    if cnt == m:
        ans += 1
    #print(ans)



print(ans)