def main():
    N,M = map(int, input().split())
    s = [[int(x) for x in input().split()] for _ in range(M)]
    p = [int(x) for x in input().split()]
    count=0
    for i in range(2**N):
        switch=[0]*N
        sw = bin(i)[2:]
        sw = "0"*(N-len(sw))+sw
        #print(sw)
        #for j in range(N):
            #switch[j] = int(sw[j])
        All=0   
        for j in range(M):
            Sum=0
            for k in s[j]:
                #if switch[k-1]==1:
                if int(sw[k-1])==1:
                    Sum+=1
            if Sum%2 == p[j]:
                All+=1
        if All==M:
            count+=1
    print(count)

main()