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

s = []

for i in range(m):

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

    k = inputs[0]

    s.append(inputs[1:])



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



res = 0

for i in range(2 ** n):

    flag = True

    bit_i = bin(i)[2:].zfill(n)

    for j in range(m):

        sum_s = 0

        for idx in s[j]:

            sum_s += int(bit_i[idx-1])

        if sum_s % 2 != p[j]:

            flag = False

            break

    if flag:

        res += 1



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

S = []

for _ in range(M):

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

    S.append(ks[1:])

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



ans = 0

for i in range(2**N):

    bi = str(bin(i))[2:]

    bi = bi.zfill(N)

    isAddable = True

    for j in range(M):

        s_sum = 0

        for s in S[j]:

            if bi[s-1] == '1':

                s_sum += 1

        if s_sum % 2 != P[j]:

            isAddable = False

            break

    if isAddable:

        ans += 1

print(ans)
n, m = list(map(int, input().split()))
s = []
for i in range(m):
    inputs = list(map(int, input().split()))
    k = inputs[0]
    s.append(inputs[1:])
p = list(map(int, input().split()))
res = 0
for i in range(2**n):
    flag = True
    bit_i = bin(i)[2:].zfill(n)
    for j in range(m):
        sum_s = 0
        for idx in s[j]:
            sum_s += int(bit_i[idx - 1])
        if sum_s % 2 != p[j]:
            flag = False
            break
    if flag:
        res += 1
print(res)

N, M = list(map(int, input().split()))
S = []
for _ in range(M):
    ks = list(map(int, input().split()))
    S.append(ks[1:])
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
    bi = str(bin(i))[2:]
    bi = bi.zfill(N)
    isAddable = True
    for j in range(M):
        s_sum = 0
        for s in S[j]:
            if bi[s - 1] == "1":
                s_sum += 1
        if s_sum % 2 != P[j]:
            isAddable = False
            break
    if isAddable:
        ans += 1
print(ans)

-n, m = list(map(int, input().split())) -s = [] -for i in range(m): -    inputs = list(map(int, input().split())) -    k = inputs[0] -    s.append(inputs[1:]) -p = list(map(int, input().split())) -res = 0 -for i in range(2**n): -    flag = True -    bit_i = bin(i)[2:].zfill(n) -    for j in range(m): -        sum_s = 0 -        for idx in s[j]: -            sum_s += int(bit_i[idx - 1]) -        if sum_s % 2 != p[j]: -            flag = False +N, M = list(map(int, input().split())) +S = [] +for _ in range(M): +    ks = list(map(int, input().split())) +    S.append(ks[1:]) +P = list(map(int, input().split())) +ans = 0 +for i in range(2**N): +    bi = str(bin(i))[2:] +    bi = bi.zfill(N) +    isAddable = True +    for j in range(M): +        s_sum = 0 +        for s in S[j]: +            if bi[s - 1] == "1": +                s_sum += 1 +        if s_sum % 2 != P[j]: +            isAddable = False -    if flag: -        res += 1 -print(res) +    if isAddable: +        ans += 1 +print(ans)