n,m=map(int,input().split())
switch=[ '0' * (10) for i in range(m)]
for i in range(m):
    li = list(map(int,input().split()))
    for j in range(len(li)):
        if j==0:
            continue
        lis = list(switch[i])
        lis[li[j]-1] = '1'
        switch[i] = ''.join(lis)
p=list(map(int,input().split()))
ans=0
# print(switch)
for i in range(2**n):
    on_switch=list(format(i,'010b')[::-1])
    flag=1
    for ii in range(m):
        s=switch[ii]
        icchi=0
        for z in range(10):
            if on_switch[z]=='1':
                if list(s)[z] == '1':
                    icchi+=1
        # print(''.join(on_switch),switch[ii])
        # print(i,ii,icchi)
        if icchi%2 != p[ii-1]:
            flag=0
            break
    if flag==1:
        ans+=1
        # print('yeah',i)
print(ans)