n,m=list(map(int,input().split()))

l=[list(map(int,input().split()))[1:] for i in range(m)]

p=list(map(int,input().split()))

form = "0" + str(n) + "b"

ans=0

for i in range(2**n):

	ptr = format(i,form)

	flg = True

	for j in range(m):

		s= sum(int(ptr[k-1]) for k in l[j])

		if s%2 != p[j]:

			flg = False

	if flg == True:

		ans+=1

print(ans)
n,m=list(map(int,input().split()))

k=[0]*m

s=[set() for i in range(m)]

for i in range(m):

  k[i],*t=list(map(int,input().split()))

  for j in range(k[i]):

    s[i].add(t[j]-1)

ans=0

p=list(map(int,input().split()))

for i in range(2**n):

  switch=[0]*n

  flag=True

  for j in range(n):

    if i>>j&1:

      switch[j]=1

  for j in range(m):

    on_cnt=0

    for k in range(n):

      if switch[k]==1 and k in s[j]:

        on_cnt+=1

    if on_cnt%2!=p[j]:

      flag=False

      break

  if flag:

    ans+=1

print(ans)
n, m = list(map(int, input().split()))
l = [list(map(int, input().split()))[1:] for i in range(m)]
p = list(map(int, input().split()))
form = "0" + str(n) + "b"
ans = 0
for i in range(2**n):
    ptr = format(i, form)
    flg = True
    for j in range(m):
        s = sum(int(ptr[k - 1]) for k in l[j])
        if s % 2 != p[j]:
            flg = False
    if flg == True:
        ans += 1
print(ans)

n, m = list(map(int, input().split()))
k = [0] * m
s = [set() for i in range(m)]
for i in range(m):
    k[i], *t = list(map(int, input().split()))
    for j in range(k[i]):
        s[i].add(t[j] - 1)
ans = 0
p = list(map(int, input().split()))
for i in range(2**n):
    switch = [0] * n
    flag = True
    for j in range(n):
        if i >> j & 1:
            switch[j] = 1
    for j in range(m):
        on_cnt = 0
        for k in range(n):
            if switch[k] == 1 and k in s[j]:
                on_cnt += 1
        if on_cnt % 2 != p[j]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

-l = [list(map(int, input().split()))[1:] for i in range(m)] +k = [0] * m +s = [set() for i in range(m)] +for i in range(m): +    k[i], *t = list(map(int, input().split())) +    for j in range(k[i]): +        s[i].add(t[j] - 1) +ans = 0 -form = "0" + str(n) + "b" -ans = 0 -    ptr = format(i, form) -    flg = True +    switch = [0] * n +    flag = True +    for j in range(n): +        if i >> j & 1: +            switch[j] = 1 -        s = sum(int(ptr[k - 1]) for k in l[j]) -        if s % 2 != p[j]: -            flg = False -    if flg == True: +        on_cnt = 0 +        for k in range(n): +            if switch[k] == 1 and k in s[j]: +                on_cnt += 1 +        if on_cnt % 2 != p[j]: +            flag = False +            break +    if flag: