# coding: utf-8

import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N, M = lr()

lights = [lr() for _ in range(M)]

P = lr()

answer = 0

for bit in range(2 ** N):

    bl = True

    for i in range(M):

        p = P[i]

        result = 0

        for s in lights[i][1:]:

            s -= 1

            if (bit >> s) & 1:

                result += 1

        if result % 2 != p:

            bl = False

    if bl:

        answer += 1

print(answer)

# coding: utf-8

import sys

import itertools



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N, M = lr()

KS = [lr() for _ in range(M)]

P = lr()

answer = 0

for pattern in itertools.product([0, 1], repeat=N):

    bl = True

    for i in range(M):

        if sum(pattern[x-1] for x in KS[i][1:]) % 2 != P[i]:

            bl = False

            break

    if bl:

        answer += 1



print(answer)

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
lights = [lr() for _ in range(M)]
P = lr()
answer = 0
for bit in range(2**N):
    bl = True
    for i in range(M):
        p = P[i]
        result = 0
        for s in lights[i][1:]:
            s -= 1
            if (bit >> s) & 1:
                result += 1
        if result % 2 != p:
            bl = False
    if bl:
        answer += 1
print(answer)

# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
KS = [lr() for _ in range(M)]
P = lr()
answer = 0
for pattern in itertools.product([0, 1], repeat=N):
    bl = True
    for i in range(M):
        if sum(pattern[x - 1] for x in KS[i][1:]) % 2 != P[i]:
            bl = False
            break
    if bl:
        answer += 1
print(answer)

+import itertools -lights = [lr() for _ in range(M)] +KS = [lr() for _ in range(M)] -for bit in range(2**N): +for pattern in itertools.product([0, 1], repeat=N): -        p = P[i] -        result = 0 -        for s in lights[i][1:]: -            s -= 1 -            if (bit >> s) & 1: -                result += 1 -        if result % 2 != p: +        if sum(pattern[x - 1] for x in KS[i][1:]) % 2 != P[i]: +            break