ks=[]

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

for i in range(m):

	ks.append(list(map(int,input().split())))

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

ans_ans=0

for i in range(2**n):

	num="0"*10+bin(i)

	ans=0

	for j in range(m):

		cnt=0

		for k in range(n):

			if num[-k-1]=="1" and k+1 in ks[j][1:]:

				cnt+=1

		if cnt%2==p[j]:

			ans+=1

	if ans==m:

		ans_ans+=1

print(ans_ans)





		

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

ks=[]

for _ in range(m):

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

	ks.append(rr)

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

def two(x):

	return "0"*(n-len(bin(x)[2:]))+bin(x)[2:]

ans=0

for i in range(2**n):

	r=two(i)

	f=1

	for j in range(m):

		cnt=0

		for k in range(ks[j][0]):

			if r[ks[j][k+1]-1]=="1":

				cnt+=1

		if cnt%2!=p[j]:

			f=0

			break

	ans+=f

print(ans)

ks = []
n, m = list(map(int, input().split()))
for i in range(m):
    ks.append(list(map(int, input().split())))
p = list(map(int, input().split()))
ans_ans = 0
for i in range(2**n):
    num = "0" * 10 + bin(i)
    ans = 0
    for j in range(m):
        cnt = 0
        for k in range(n):
            if num[-k - 1] == "1" and k + 1 in ks[j][1:]:
                cnt += 1
        if cnt % 2 == p[j]:
            ans += 1
    if ans == m:
        ans_ans += 1
print(ans_ans)

n, m = list(map(int, input().split()))
ks = []
for _ in range(m):
    rr = list(map(int, input().split()))
    ks.append(rr)
p = list(map(int, input().split()))


def two(x):
    return "0" * (n - len(bin(x)[2:])) + bin(x)[2:]


ans = 0
for i in range(2**n):
    r = two(i)
    f = 1
    for j in range(m):
        cnt = 0
        for k in range(ks[j][0]):
            if r[ks[j][k + 1] - 1] == "1":
                cnt += 1
        if cnt % 2 != p[j]:
            f = 0
            break
    ans += f
print(ans)

+n, m = list(map(int, input().split())) -n, m = list(map(int, input().split())) -for i in range(m): -    ks.append(list(map(int, input().split()))) +for _ in range(m): +    rr = list(map(int, input().split())) +    ks.append(rr) -ans_ans = 0 + + +def two(x): +    return "0" * (n - len(bin(x)[2:])) + bin(x)[2:] + + +ans = 0 -    num = "0" * 10 + bin(i) -    ans = 0 +    r = two(i) +    f = 1 -        for k in range(n): -            if num[-k - 1] == "1" and k + 1 in ks[j][1:]: +        for k in range(ks[j][0]): +            if r[ks[j][k + 1] - 1] == "1": -        if cnt % 2 == p[j]: -            ans += 1 -    if ans == m: -        ans_ans += 1 -print(ans_ans) +        if cnt % 2 != p[j]: +            f = 0 +            break +    ans += f +print(ans)