N,M = list(map(int,input().split()))

S = []

for i in range(M) :

    B = list(map(int,input().split()))[1:]

    for i in range(len(B)) :

        B[i] -= 1

    S.append(B)

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



ans = 0



for bit in range((1 << N)) :

    A = []

    for k in range(N) :

        if bit & (1 << k) :

            A.append(k)

    #print(A)

    for i in range(M) :

        cnt = 0

        for j in range(len(S[i])) :

            if S[i][j] in A :

                cnt += 1

        if (cnt % 2) != P[i] :

            break

    else :

        ans += 1

print(ans)

N,M = list(map(int,input().split()))



S = []

for i in range(M) :

    L = list(map(int,input().split()))[1:]

    for j in range(len(L)) :

        L[j] -= 1

    S.append(L)



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



ans = 0



for bit in range(1 << N) :

    A = []

    for k in range(N) :

        if bit & (1 << k) :

            A.append(k)

    for i in range(len(S)) :

        cnt = 0

        for s in S[i] :

            if s in A :

                cnt += 1

        if (cnt % 2) != P[i] :

            break

    else :

        ans += 1

print(ans)

N, M = list(map(int, input().split()))
S = []
for i in range(M):
    B = list(map(int, input().split()))[1:]
    for i in range(len(B)):
        B[i] -= 1
    S.append(B)
P = list(map(int, input().split()))
ans = 0
for bit in range((1 << N)):
    A = []
    for k in range(N):
        if bit & (1 << k):
            A.append(k)
    # print(A)
    for i in range(M):
        cnt = 0
        for j in range(len(S[i])):
            if S[i][j] in A:
                cnt += 1
        if (cnt % 2) != P[i]:
            break
    else:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))
S = []
for i in range(M):
    L = list(map(int, input().split()))[1:]
    for j in range(len(L)):
        L[j] -= 1
    S.append(L)
P = list(map(int, input().split()))
ans = 0
for bit in range(1 << N):
    A = []
    for k in range(N):
        if bit & (1 << k):
            A.append(k)
    for i in range(len(S)):
        cnt = 0
        for s in S[i]:
            if s in A:
                cnt += 1
        if (cnt % 2) != P[i]:
            break
    else:
        ans += 1
print(ans)

-    B = list(map(int, input().split()))[1:] -    for i in range(len(B)): -        B[i] -= 1 -    S.append(B) +    L = list(map(int, input().split()))[1:] +    for j in range(len(L)): +        L[j] -= 1 +    S.append(L) -for bit in range((1 << N)): +for bit in range(1 << N): -    # print(A) -    for i in range(M): +    for i in range(len(S)): -        for j in range(len(S[i])): -            if S[i][j] in A: +        for s in S[i]: +            if s in A: