n,m = map(int,input().split())
s = []
k = []
for i in range(m):
    s_in = list(map(int,input().split()))
    s.append(s_in[1:])
    k.append(s_in[0])
p = list(map(int,input().split()))
ans = 0
def bfs(switch):
    global ans
    if len(switch)==n:
        ok = 1 #全部の電球がつく
        for i in range(m):
            on_cnt=0
            for j in range(k[i]):
                if switch[j-1]==1:
                    on_cnt+=1
            if on_cnt%2!=p[i]:
                ok = 0
        if ok:
            ans+=1
    else:
        bfs(switch+[0])
        bfs(switch+[1])
bfs([])
print(ans)