def check(k,p,list):
    count = 0
    res = 0
    # print(list)
    for i in range(len(k)):
        for j in range(k[i][0]):
            if(k[i][j+1] in list):
                count += 1
        if count % 2 == p[i]:
            res += 1
    # print(count)
    return res == len(k)

n,m = map(int,input().split())
sw = []

for i in range(m):
    sw.append(list(map(int,input().split())))
    # print()
    # print(sw[i])
p = list(map(int,input().split()))
res = 0
# print(p)

for i in range(2**n):
    list = []
    for j in range(n):
        if(i >> j) & 1 == 1:
            list.append(j+1)
    if(check(sw,p,list)):
        res += 1
print(res)