import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]


n,m=map(int,input().split())
ks=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))

bit=list(product(range(2),repeat=n))
ans=0
for bi in bit:
    plst=[0]*m
    for j in range(m):
        for k in range(ks[j][0]):
            plst[j]+=bi[ks[j][1+k]-1]
    
    for j in range(m):
        if plst[j]%2!=p[j]:
            break
    else:
        ans+=1
print(ans) import bisect, copy, heapq, math, sys bisect copy heapq math sys from collections import * from functools import lru_cache from itertools import accumulate, combinations, permutations, product def input():
    return sys.stdin.readline()[:-1] input return sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 def ruiseki(lst):
    return [0]+list(accumulate(lst)) ruiseki return [0]+list(accumulate(lst)) [0]+list(accumulate(lst)) [0] 0 list(accumulate(lst)) list accumulate(lst) accumulate lst lst lst def celi(a,b):
    return -(-a//b) celi return -(-a//b) -(-a//b) -a//b -a a b a a b b sys.setrecursionlimit(5000000) sys.setrecursionlimit sys setrecursionlimit 5000000 mod=pow(10,9)+7 mod pow(10,9)+7 pow(10,9) pow 10 9 7 chr(ord('a') + i) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) chr(ord('a') + i) chr ord('a') + i ord('a') ord 'a' i al=[chr(ord('a') + i) for i in range(26)] al [chr(ord('a') + i) for i in range(26)] direction=[[1,0],[0,1],[-1,0],[0,-1]] direction [[1,0],[0,1],[-1,0],[0,-1]] [1,0] 1 0 [0,1] 0 1 [-1,0] -1 0 [0,-1] 0 -1 n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m list(map(int,input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ks=[list(map(int,input().split())) for i in range(m)] ks [list(map(int,input().split())) for i in range(m)] p=list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split bit=list(product(range(2),repeat=n)) bit list(product(range(2),repeat=n)) list product(range(2),repeat=n) product range(2) range 2 repeat=n repeat n ans=0 ans 0 for bi in bit:
    plst=[0]*m
    for j in range(m):
        for k in range(ks[j][0]):
            plst[j]+=bi[ks[j][1+k]-1]
    
    for j in range(m):
        if plst[j]%2!=p[j]:
            break
    else:
        ans+=1 bi bit plst=[0]*m plst [0]*m [0] 0 m for j in range(m):
        for k in range(ks[j][0]):
            plst[j]+=bi[ks[j][1+k]-1]
    
     j range(m) range m for k in range(ks[j][0]):
            plst[j]+=bi[ks[j][1+k]-1]
    
     k range(ks[j][0]) range ks[j][0] [j] ks j 0 plst[j]+=bi[ks[j][1+k]-1] plst[j] plst j bi[ks[j][1+k]-1] bi ks[j][1+k]-1 ks[j][1+k] [j] ks j 1+k 1 k 1 for j in range(m):
        if plst[j]%2!=p[j]:
            break
    else:
        ans+=1 j range(m) range m if plst[j]%2!=p[j]:
            break
     plst[j]%2!=p[j] plst[j]%2 plst[j] plst j 2 p[j] p j break ans+=1 ans 1 print(ans) print ans direction=[[1,0],[0,1],[-1,0],[0,-1]] [[1,0],[0,1],[-1,0],[0,-1]] direction mod=pow(10,9)+7 pow(10,9)+7 mod p=list(map(int,input().split())) list(map(int,input().split())) p ks=[list(map(int,input().split())) for i in range(m)] [list(map(int,input().split())) for i in range(m)] ks def celi(a,b):
    return -(-a//b) def celi(a,b):
    return -(-a//b) celi bit=list(product(range(2),repeat=n)) list(product(range(2),repeat=n)) bit m=map(int,input().split()) map(int,input().split()) m def input():
    return sys.stdin.readline()[:-1] def input():
    return sys.stdin.readline()[:-1] input ans+=1 1 ans ans=0 0 ans al=[chr(ord('a') + i) for i in range(26)] [chr(ord('a') + i) for i in range(26)] al n,m=map(int,input().split()) map(int,input().split()) n plst=[0]*m [0]*m plst def ruiseki(lst):
    return [0]+list(accumulate(lst)) def ruiseki(lst):
    return [0]+list(accumulate(lst)) ruiseki
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]


n,m=map(int,input().split())
ks=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))

bit=list(product(range(2),repeat=n))
ans=0
for bi in bit:
    plst=[0]*m
    for j in range(m):
        for k in range(ks[j][0]):
            plst[j]+=bi[ks[j][1+k]-1]
    
    for j in range(m):
        if plst[j]%2!=p[j]:
            break
    else:
        ans+=1
print(ans)