N,M=list(map(int,input().split()))

k=[0]*M

s=[[] for _ in range(M)]



for i in range(M):

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

    k[i]=a[0]

    s[i]=a[1:]

    s[i].sort()



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

    

ans=0

for i in range(pow(2,N)):

    light=0

    for j in range(M):

        temp=0

        for kk in range(k[j]):

            a=i>>(s[j][kk]-1)

            if a&1==1:

                temp+=1

        if temp%2!=p[j]:

            break

        light+=1

    if light==M:

        ans+=1

               

print(ans)







import sys

input = sys.stdin.readline



def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))



def main():

    mod=10**9+7

    N,M=MI()

    s=[]

    for i in range(M):

        L=LI()

        s.append(L[1:])

    p=LI()

    

    import itertools

    

    ans=0

    for ite in itertools.product([0,1], repeat=N):

        flag=1

        for i in range(M):

            temp=0

            for ss in s[i]:

                if ite[ss-1]:

                    temp+=1

            if temp%2==p[i]:

                pass

            else:

                flag=0

        if flag:

            ans+=1

            

    print(ans)

                

                

            

        



main()

N, M = list(map(int, input().split()))
k = [0] * M
s = [[] for _ in range(M)]
for i in range(M):
    a = list(map(int, input().split()))
    k[i] = a[0]
    s[i] = a[1:]
    s[i].sort()
p = list(map(int, input().split()))
ans = 0
for i in range(pow(2, N)):
    light = 0
    for j in range(M):
        temp = 0
        for kk in range(k[j]):
            a = i >> (s[j][kk] - 1)
            if a & 1 == 1:
                temp += 1
        if temp % 2 != p[j]:
            break
        light += 1
    if light == M:
        ans += 1
print(ans)

import sys

input = sys.stdin.readline


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def main():
    mod = 10**9 + 7
    N, M = MI()
    s = []
    for i in range(M):
        L = LI()
        s.append(L[1:])
    p = LI()
    import itertools

    ans = 0
    for ite in itertools.product([0, 1], repeat=N):
        flag = 1
        for i in range(M):
            temp = 0
            for ss in s[i]:
                if ite[ss - 1]:
                    temp += 1
            if temp % 2 == p[i]:
                pass
            else:
                flag = 0
        if flag:
            ans += 1
    print(ans)


main()

-N, M = list(map(int, input().split())) -k = [0] * M -s = [[] for _ in range(M)] -for i in range(M): -    a = list(map(int, input().split())) -    k[i] = a[0] -    s[i] = a[1:] -    s[i].sort() -p = list(map(int, input().split())) -ans = 0 -for i in range(pow(2, N)): -    light = 0 -    for j in range(M): -        temp = 0 -        for kk in range(k[j]): -            a = i >> (s[j][kk] - 1) -            if a & 1 == 1: -                temp += 1 -        if temp % 2 != p[j]: -            break -        light += 1 -    if light == M: -        ans += 1 -print(ans) +import sys + +input = sys.stdin.readline + + +def I(): +    return int(eval(input())) + + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def main(): +    mod = 10**9 + 7 +    N, M = MI() +    s = [] +    for i in range(M): +        L = LI() +        s.append(L[1:]) +    p = LI() +    import itertools + +    ans = 0 +    for ite in itertools.product([0, 1], repeat=N): +        flag = 1 +        for i in range(M): +            temp = 0 +            for ss in s[i]: +                if ite[ss - 1]: +                    temp += 1 +            if temp % 2 == p[i]: +                pass +            else: +                flag = 0 +        if flag: +            ans += 1 +    print(ans) + + +main()