import itertools

n, m = [int(i) for i in input().split()]
s = []
k = []
for i in range(m):
    moyo = input().split()
    k.append(int(moyo[0]))
    s.append(moyo[1:])
p = input().split()
switch = ("on", "off")
ans = list(itertools.product(['on', 'off'], repeat = n))
for i in range(m):
    if(p[i] == 0):
        ans.delete(ans.count("on") & 2 == 1)
    else:
        ans.delete(ans.count("on") & 2 == 0)
print(len(ans))