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

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

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

cnt=0

for i in range(2**n):

    pattern=format(i,"b").zfill(n)

    point=0

    for j in range(m):

        swi=0

        for k in S[j]:

            if pattern[k-1]=="1":swi +=1

        if swi%2==P[j]:point +=1

    if point==m:cnt +=1

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

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

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



cnt=0

for i in range(2**n):

    Q=0

    light=set([i+1 for i,j in enumerate(format(i,"b").zfill(n)[::-1]) if j=="1"])

    for k,j in enumerate(S):

        if len(light&set(j))%2==P[k]:Q +=1

    if Q==m:cnt +=1



print(cnt)
n, m = list(map(int, input().split()))
S = [list(map(int, input().split()))[1:] for i in range(m)]
P = list(map(int, input().split()))
cnt = 0
for i in range(2**n):
    pattern = format(i, "b").zfill(n)
    point = 0
    for j in range(m):
        swi = 0
        for k in S[j]:
            if pattern[k - 1] == "1":
                swi += 1
        if swi % 2 == P[j]:
            point += 1
    if point == m:
        cnt += 1
print(cnt)

n, m = list(map(int, input().split()))
S = [list(map(int, input().split()))[1:] for i in range(m)]
P = list(map(int, input().split()))
cnt = 0
for i in range(2**n):
    Q = 0
    light = set(
        [i + 1 for i, j in enumerate(format(i, "b").zfill(n)[::-1]) if j == "1"]
    )
    for k, j in enumerate(S):
        if len(light & set(j)) % 2 == P[k]:
            Q += 1
    if Q == m:
        cnt += 1
print(cnt)

-    pattern = format(i, "b").zfill(n) -    point = 0 -    for j in range(m): -        swi = 0 -        for k in S[j]: -            if pattern[k - 1] == "1": -                swi += 1 -        if swi % 2 == P[j]: -            point += 1 -    if point == m: +    Q = 0 +    light = set( +        [i + 1 for i, j in enumerate(format(i, "b").zfill(n)[::-1]) if j == "1"] +    ) +    for k, j in enumerate(S): +        if len(light & set(j)) % 2 == P[k]: +            Q += 1 +    if Q == m: