# -*- coding: utf-8 -*-
"""
Created on Fri Apr  3 14:23:44 2020

@author: liang
"""

N, M = map(int,input().split())
bulbs = [list(map(int,input().split()))[1:] for _ in range(M)]
p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    lights = [1 if (i>>j)&1 == 1 else 0 for j in range(N)]
    if all(sum(lights[x-1] for x in bulbs[k])%2 == p[k] for k in range(len(bulbs))):
            ans += 1



print(bulbs)
print(p)
print(ans)