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

k = []

s = []

for i in range(m):

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

    k.append(l[0])

    s.append(l[1:])

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



ans = 0

for bit in range(2 ** n):

    q = 1

    for i in range(m):

        sum = 0

        for j in range(k[i]):

            if (bit >> (s[i][j] - 1)) & 1:

                sum += 1

        if sum % 2 != p[i]:

            q = 0

    if q == 1:

        ans += 1



print(ans)

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

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

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

ans = 0

for i in range(2 ** N):  # all comb

    for j in range(M):  # k loop

        c = 0

        for k in range(N):  # s loop

            if ((i >> k) & 1) and (k + 1) in s[j][1:]:

                c += 1

        if c % 2 != p[j]:

            break

        elif j == M - 1:

            ans += 1

print(ans)

n, m = list(map(int, input().split()))
k = []
s = []
for i in range(m):
    l = list(map(int, input().split()))
    k.append(l[0])
    s.append(l[1:])
p = list(map(int, input().split()))
ans = 0
for bit in range(2**n):
    q = 1
    for i in range(m):
        sum = 0
        for j in range(k[i]):
            if (bit >> (s[i][j] - 1)) & 1:
                sum += 1
        if sum % 2 != p[i]:
            q = 0
    if q == 1:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):  # all comb
    for j in range(M):  # k loop
        c = 0
        for k in range(N):  # s loop
            if ((i >> k) & 1) and (k + 1) in s[j][1:]:
                c += 1
        if c % 2 != p[j]:
            break
        elif j == M - 1:
            ans += 1
print(ans)

-n, m = list(map(int, input().split())) -k = [] -s = [] -for i in range(m): -    l = list(map(int, input().split())) -    k.append(l[0]) -    s.append(l[1:]) +N, M = list(map(int, input().split())) +s = [list(map(int, input().split())) for i in range(M)] -for bit in range(2**n): -    q = 1 -    for i in range(m): -        sum = 0 -        for j in range(k[i]): -            if (bit >> (s[i][j] - 1)) & 1: -                sum += 1 -        if sum % 2 != p[i]: -            q = 0 -    if q == 1: -        ans += 1 +for i in range(2**N):  # all comb +    for j in range(M):  # k loop +        c = 0 +        for k in range(N):  # s loop +            if ((i >> k) & 1) and (k + 1) in s[j][1:]: +                c += 1 +        if c % 2 != p[j]: +            break +        elif j == M - 1: +            ans += 1