import sys

input = sys.stdin.readline



from itertools import product



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

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

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



ans = 0

for p in product([0,1],repeat=N):

    can = 0

    for i in range(M):

        res = 0

        for s in S[i]:

            if p[s-1] == 1:

                res += 1

        res %= 2

        if res == P[i]:

            can += 1

    if can == M:

        ans += 1



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

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

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



ans = 0



for mask in range(0,1<<N):

    flag = True

    for i, line in enumerate(S):

        cnt = 0

        for s in line:

            if ((mask >> (s-1) & 1)):

                cnt += 1

        if cnt % 2 != P[i]:

            flag = False

            break

    if flag:

        ans += 1



print(ans)
import sys

input = sys.stdin.readline
from itertools import product

N, M = list(map(int, input().split()))
S = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for p in product([0, 1], repeat=N):
    can = 0
    for i in range(M):
        res = 0
        for s in S[i]:
            if p[s - 1] == 1:
                res += 1
        res %= 2
        if res == P[i]:
            can += 1
    if can == M:
        ans += 1
print(ans)

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

-import sys - -input = sys.stdin.readline -from itertools import product - -for p in product([0, 1], repeat=N): -    can = 0 -    for i in range(M): -        res = 0 -        for s in S[i]: -            if p[s - 1] == 1: -                res += 1 -        res %= 2 -        if res == P[i]: -            can += 1 -    if can == M: +for mask in range(0, 1 << N): +    flag = True +    for i, line in enumerate(S): +        cnt = 0 +        for s in line: +            if mask >> (s - 1) & 1: +                cnt += 1 +        if cnt % 2 != P[i]: +            flag = False +            break +    if flag: