#!/usr/bin/python
# coding: UTF-8

n,m = map(int,input().split())

s = []
for i in range(m):
    s += [tuple(map(int,input().split())),]

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

ret = 0
all = [(str(bin(i)))[2:].zfill(m) for i in range(2 ** n),]
all = [[int(i) for i in case] for case in all,]
for case in all:
    # print("------------------------------------------------")
    # print("[case = ",case,"]")
    flag = 0
    for num,i in enumerate(s):
        if flag == 1:
            continue

        # print("  [case = ",i[1:],"]")

        sw = [0 for z in range(n),]
        # print("sw",sw)
        for k in i[1:]:
            sw[k-1] = 1

        # print(sw,case)
        # print(sum(i*j for i,j in zip(sw,case)) % 2," =? ",p[num])
        if (sum(i*j for i,j in zip(sw,case),) % 2) != p[num]:
            flag = 1
        # print("flag is ",flag)
           
    if flag == 0:
        # print(case," is ok.")
        ret += 1

print(ret)