# -*- coding: utf-8 -*-
"""
Created on Sun May 26 20:56:00 2019

@author: Yamazaki Kenichi
"""

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

ans = 0
for i in range(2**N):
    t = '{:010b}'.format(i)
    flg = True
    for j in range(M):
        tmp = 0
        for k in range(ks[j][0]):
            tmp += int(t[-ks[j][k]])
#        print(i,j,t,tmp,ans)
        if tmp%2 == p[j]:
            continue
        else:
            flg = False
            break
    if flg:
        ans += 1

            
print(ans)
