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

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

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

blst = []

cnt = 0

for i in range(2 ** N):

    slst = []

    for j in range(N):

        if i >> j & 1:

            slst.append(j)

    blst.append(slst)



for i in blst:

    ansF = False

    for j in range(M):

        ctmp1 = 0

        for k in i:

            if ks[j][1:].count(k + 1) == 1:

                ctmp1 += 1

        if ctmp1 % 2 == p[j]:

            ansF = True

        else:

            ansF = False

            break

    if ansF:

        cnt += 1



print(cnt)


def dfs(cnt):

    global ans

    if cnt == N:

        onF = True

        for i in range(M):

            tmp = 0

            for j in range(ks[i][0]):

                if bit[ks[i][j + 1] - 1] == 1:

                    tmp += 1

            if tmp % 2 != p[i]:

                onF = False

                break

        if onF:

            ans += 1

        return

    for i in range(2):

        bit[cnt] = i

        dfs(cnt + 1)





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

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

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

bit = [0] * N

ans = 0

dfs(0)

print(ans)
N, M = list(map(int, input().split()))
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
blst = []
cnt = 0
for i in range(2**N):
    slst = []
    for j in range(N):
        if i >> j & 1:
            slst.append(j)
    blst.append(slst)
for i in blst:
    ansF = False
    for j in range(M):
        ctmp1 = 0
        for k in i:
            if ks[j][1:].count(k + 1) == 1:
                ctmp1 += 1
        if ctmp1 % 2 == p[j]:
            ansF = True
        else:
            ansF = False
            break
    if ansF:
        cnt += 1
print(cnt)

def dfs(cnt):
    global ans
    if cnt == N:
        onF = True
        for i in range(M):
            tmp = 0
            for j in range(ks[i][0]):
                if bit[ks[i][j + 1] - 1] == 1:
                    tmp += 1
            if tmp % 2 != p[i]:
                onF = False
                break
        if onF:
            ans += 1
        return
    for i in range(2):
        bit[cnt] = i
        dfs(cnt + 1)


N, M = list(map(int, input().split()))
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
bit = [0] * N
ans = 0
dfs(0)
print(ans)

+def dfs(cnt): +    global ans +    if cnt == N: +        onF = True +        for i in range(M): +            tmp = 0 +            for j in range(ks[i][0]): +                if bit[ks[i][j + 1] - 1] == 1: +                    tmp += 1 +            if tmp % 2 != p[i]: +                onF = False +                break +        if onF: +            ans += 1 +        return +    for i in range(2): +        bit[cnt] = i +        dfs(cnt + 1) + + -blst = [] -cnt = 0 -for i in range(2**N): -    slst = [] -    for j in range(N): -        if i >> j & 1: -            slst.append(j) -    blst.append(slst) -for i in blst: -    ansF = False -    for j in range(M): -        ctmp1 = 0 -        for k in i: -            if ks[j][1:].count(k + 1) == 1: -                ctmp1 += 1 -        if ctmp1 % 2 == p[j]: -            ansF = True -        else: -            ansF = False -            break -    if ansF: -        cnt += 1 -print(cnt) +bit = [0] * N +ans = 0 +dfs(0) +print(ans)