def main():

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

    s=[list(map(int,input().split()))[1:] for i in range(M)]

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

    

    ans=0

    for i in range(2**N):

        flag=True

        for j in range(M):

            if not ([(i>>k-1)&1 for k in s[j]].count(1)%2==p[j]):

                flag=False

                

        if flag:

            ans+=1

            

    print(ans)



if __name__=="__main__":

    main()
import itertools



def main():

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

    sw =[list(map(int, input().split())) for _ in range(M)]

    p=[int(x) for x in input().split()]

    ans=0

    

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

        onof=True

        for j in range(M):

            counter=0

            for k in sw[j][1:]:

                counter+=i[k-1]

            if counter%2!=p[j]:

                onof=False

                break

        if onof:

            ans+=1

    print(ans)

    

if __name__=="__main__":

    main()
def main():
    N, M = list(map(int, input().split()))
    s = [list(map(int, input().split()))[1:] for i in range(M)]
    p = list(map(int, input().split()))
    ans = 0
    for i in range(2**N):
        flag = True
        for j in range(M):
            if not ([(i >> k - 1) & 1 for k in s[j]].count(1) % 2 == p[j]):
                flag = False
        if flag:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

import itertools


def main():
    N, M = list(map(int, input().split()))
    sw = [list(map(int, input().split())) for _ in range(M)]
    p = [int(x) for x in input().split()]
    ans = 0
    for i in itertools.product([0, 1], repeat=N):
        onof = True
        for j in range(M):
            counter = 0
            for k in sw[j][1:]:
                counter += i[k - 1]
            if counter % 2 != p[j]:
                onof = False
                break
        if onof:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

+import itertools + + -    s = [list(map(int, input().split()))[1:] for i in range(M)] -    p = list(map(int, input().split())) +    sw = [list(map(int, input().split())) for _ in range(M)] +    p = [int(x) for x in input().split()] -    for i in range(2**N): -        flag = True +    for i in itertools.product([0, 1], repeat=N): +        onof = True -            if not ([(i >> k - 1) & 1 for k in s[j]].count(1) % 2 == p[j]): -                flag = False -        if flag: +            counter = 0 +            for k in sw[j][1:]: +                counter += i[k - 1] +            if counter % 2 != p[j]: +                onof = False +                break +        if onof: