import sys
import os
from itertools import combinations

def file_input():
    f = open('ABC128/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,M=map(int, input().split()) #N:switch M:light
    s=[[] for i in range(M)]
    k=[]
    for i in range(M):
        tmp=list(map(int, input().split()))
        k.append(tmp[0])
        s[i]=tmp[1:]
    p=list(map(int, input().split()))

    out=0
    for i in range(1,N+1):
        for li in combinations(range(N),i):
            # print(li)
            on=0
            for m in range(M):
                tmp=0
                for j in range(k[m]):
                    # print("m:"+str(m)+" k:"+str(j))
                    for c in li:
                        if s[m][j]==c+1:
                            tmp+=1
                if tmp%2==p[m]:
                    on+=1
            if on==M:
                # print(li)
                out+=1

    print(out)


if __name__ == '__main__':
    main()
