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

s = []

ans = 0

for _ in range(M):

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

    s.append(temp[1:])

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

for i in range(2 ** N):

    flag = 1

    flag_1 = 1

    sw = bin(i)[2:]

    sw = sw.zfill(N)

    for j in range(M):

        sumsw = 0

        for k in s[j]:

            sumsw += int(sw[k-1])

        if sumsw % 2 != p[j]:

            flag = 0

            flag_1 = 0

            break

        if flag_1 == 0:

            break

    if flag:

        ans += 1

print(ans)
import sys

input = sys.stdin.readline



N, M = [int(x) for x in input().split()]

k = []

s = []

for _ in range(M):

    tmp = [int(x) for x in input().split()]

    k.append(tmp[0])

    s.append(tmp[1:])

p = [int(x) for x in input().split()]



ans = 0



for i in range(2 ** N):

    flag = 1

    for j in range(M):

        cnt = 0

        for k in s[j]:

            cnt += (i >> (k - 1)) & 1

        if cnt % 2 != p[j]:

            flag = 0

            break

    ans += flag



print(ans)





N, M = list(map(int, input().split()))
s = []
ans = 0
for _ in range(M):
    temp = list(map(int, input().split()))
    s.append(temp[1:])
p = list(map(int, input().split()))
for i in range(2**N):
    flag = 1
    flag_1 = 1
    sw = bin(i)[2:]
    sw = sw.zfill(N)
    for j in range(M):
        sumsw = 0
        for k in s[j]:
            sumsw += int(sw[k - 1])
        if sumsw % 2 != p[j]:
            flag = 0
            flag_1 = 0
            break
        if flag_1 == 0:
            break
    if flag:
        ans += 1
print(ans)

import sys

input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
k = []
s = []
for _ in range(M):
    tmp = [int(x) for x in input().split()]
    k.append(tmp[0])
    s.append(tmp[1:])
p = [int(x) for x in input().split()]
ans = 0
for i in range(2**N):
    flag = 1
    for j in range(M):
        cnt = 0
        for k in s[j]:
            cnt += (i >> (k - 1)) & 1
        if cnt % 2 != p[j]:
            flag = 0
            break
    ans += flag
print(ans)

-N, M = list(map(int, input().split())) +import sys + +input = sys.stdin.readline +N, M = [int(x) for x in input().split()] +k = [] +for _ in range(M): +    tmp = [int(x) for x in input().split()] +    k.append(tmp[0]) +    s.append(tmp[1:]) +p = [int(x) for x in input().split()] -for _ in range(M): -    temp = list(map(int, input().split())) -    s.append(temp[1:]) -p = list(map(int, input().split())) -    flag_1 = 1 -    sw = bin(i)[2:] -    sw = sw.zfill(N) -        sumsw = 0 +        cnt = 0 -            sumsw += int(sw[k - 1]) -        if sumsw % 2 != p[j]: +            cnt += (i >> (k - 1)) & 1 +        if cnt % 2 != p[j]: -            flag_1 = 0 -        if flag_1 == 0: -            break -    if flag: -        ans += 1 +    ans += flag