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



S = [list(map(int, input().split())) for _ in range(M)]

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



ans = 0

temp = [0]*N

for i in range(2**N):

    for j in range(N):

        if((i >> j) & 1):

            temp[j] = 1



    for k in range(M):

        count = 0

        for l in range(1, len(S[k])):

            if temp[S[k][l] - 1] == 1:

                count += 1

        if count % 2 != p[k]:

            break

    else:

        ans += 1

    temp = [0]*N



print(ans)

import itertools



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

data = [list(map(int, input().split())) for _ in range(M)]

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



# スイッチが付いているか付いていないかを表す集合

ans = 0

for bit in itertools.product([0, 1], repeat=N):

    for d, p in zip(data, P):

        cnt = 0

        for i in d[1:]:

            if bit[i - 1] == 1:

                cnt += 1

        if cnt % 2 != p:

            break

    else:

        ans += 1



print(ans)
N, M = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
temp = [0] * N
for i in range(2**N):
    for j in range(N):
        if (i >> j) & 1:
            temp[j] = 1
    for k in range(M):
        count = 0
        for l in range(1, len(S[k])):
            if temp[S[k][l] - 1] == 1:
                count += 1
        if count % 2 != p[k]:
            break
    else:
        ans += 1
    temp = [0] * N
print(ans)

import itertools

N, M = list(map(int, input().split()))
data = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))
# スイッチが付いているか付いていないかを表す集合
ans = 0
for bit in itertools.product([0, 1], repeat=N):
    for d, p in zip(data, P):
        cnt = 0
        for i in d[1:]:
            if bit[i - 1] == 1:
                cnt += 1
        if cnt % 2 != p:
            break
    else:
        ans += 1
print(ans)

+import itertools + -S = [list(map(int, input().split())) for _ in range(M)] -p = list(map(int, input().split())) +data = [list(map(int, input().split())) for _ in range(M)] +P = list(map(int, input().split())) +# スイッチが付いているか付いていないかを表す集合 -temp = [0] * N -for i in range(2**N): -    for j in range(N): -        if (i >> j) & 1: -            temp[j] = 1 -    for k in range(M): -        count = 0 -        for l in range(1, len(S[k])): -            if temp[S[k][l] - 1] == 1: -                count += 1 -        if count % 2 != p[k]: +for bit in itertools.product([0, 1], repeat=N): +    for d, p in zip(data, P): +        cnt = 0 +        for i in d[1:]: +            if bit[i - 1] == 1: +                cnt += 1 +        if cnt % 2 != p: -    temp = [0] * N