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

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

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

ans = 0

switch_st = 0

cnt = 0



while switch_st != 2**n:

    switch_on = { i+1 for i in range(n) if switch_st>>i & 1 == 1}

    for i in range(m):

        switch_cnt = len(switch_on & set(k[i][1:]))

        if switch_cnt %2 == p[i]:

            cnt += 1

    else:

        if cnt == m:

            ans += 1

    cnt = 0

    switch_st += 1



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

S = [[int(i)-1 for i in input().split()] for _ in range(M)]

P = [int(i) for i in input().split()]



ans = 0

for i in range(1<<N):

    for j in range(M):

        cnt = 0

        for s in S[j][1:]:

            if i >> s & 1: cnt += 1

        if cnt%2 != P[j]: break

    else:

        ans += 1



print(ans)
n, m = list(map(int, input().split()))
k = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
switch_st = 0
cnt = 0
while switch_st != 2**n:
    switch_on = {i + 1 for i in range(n) if switch_st >> i & 1 == 1}
    for i in range(m):
        switch_cnt = len(switch_on & set(k[i][1:]))
        if switch_cnt % 2 == p[i]:
            cnt += 1
    else:
        if cnt == m:
            ans += 1
    cnt = 0
    switch_st += 1
print(ans)

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

-n, m = list(map(int, input().split())) -k = [list(map(int, input().split())) for i in range(m)] -p = list(map(int, input().split())) +N, M = list(map(int, input().split())) +S = [[int(i) - 1 for i in input().split()] for _ in range(M)] +P = [int(i) for i in input().split()] -switch_st = 0 -cnt = 0 -while switch_st != 2**n: -    switch_on = {i + 1 for i in range(n) if switch_st >> i & 1 == 1} -    for i in range(m): -        switch_cnt = len(switch_on & set(k[i][1:])) -        if switch_cnt % 2 == p[i]: -            cnt += 1 +for i in range(1 << N): +    for j in range(M): +        cnt = 0 +        for s in S[j][1:]: +            if i >> s & 1: +                cnt += 1 +        if cnt % 2 != P[j]: +            break -        if cnt == m: -            ans += 1 -    cnt = 0 -    switch_st += 1 +        ans += 1