#ABC128C-Switches.py

from sys import stdin
import itertools

input = stdin.readline

N, M = list(map(int, input().split()))
switches = [[0 for _ in range(M)] for _ in range(N)]
allSwitches = [i for i in range(N)]
totalNumber = 0

for i in range(M):
    ks = list(map(int, input().split()))
    for j in range(1,len(ks)):
        switches[ks[j]-1][i] = 1

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

def check(list):
    if P == [a%2 for a in list]:
        return 1
    else:
        return 0

for i in range(N):
    cList = list(itertools.combinations(allSwitches,i+1))
    for clist in cList:
        sumList = [0 for _ in range(N)]
        for c in clist:
            sumList = [x+y for (x,y) in zip(sumList,switches[c])]
        totalNumber += check(sumList)

print(totalNumber)
