N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append(tuple(map(int, input().split())))
P = tuple(map(int, input().split()))
import itertools
def hantei(A, RETU, P):
    for i in range(len(A)):
        count = 0
        for k in RETU:
            if k in A[i][1:]:
                count += 1
        if not count % 2 == P[i]:
            return False
    return True
ans = 0
for i in range(1, N + 1):
    for k in itertools.combinations(range(1, N + 1), i):
        if hantei(A, k, P):
            ans += 1
if hantei(A, [0], P):
    ans += 1
print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = [] A [] for _ in range(M):
    A.append(tuple(map(int, input().split()))) _ range(M) range M A.append(tuple(map(int, input().split()))) A.append A append tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split P = tuple(map(int, input().split())) P tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split import itertools itertools def hantei(A, RETU, P):
    for i in range(len(A)):
        count = 0
        for k in RETU:
            if k in A[i][1:]:
                count += 1
        if not count % 2 == P[i]:
            return False
    return True hantei for i in range(len(A)):
        count = 0
        for k in RETU:
            if k in A[i][1:]:
                count += 1
        if not count % 2 == P[i]:
            return False
     i range(len(A)) range len(A) len A count = 0 count 0 for k in RETU:
            if k in A[i][1:]:
                count += 1
         k RETU if k in A[i][1:]:
                count += 1
         k in A[i][1:] k A[i][1:] [i] A i 1: 1 count += 1 count 1 if not count % 2 == P[i]:
            return False
     not count % 2 == P[i] count % 2 == P[i] count % 2 count 2 P[i] P i return False False return True True A A RETU RETU P P ans = 0 ans 0 for i in range(1, N + 1):
    for k in itertools.combinations(range(1, N + 1), i):
        if hantei(A, k, P):
            ans += 1 i range(1, N + 1) range 1 N + 1 N 1 for k in itertools.combinations(range(1, N + 1), i):
        if hantei(A, k, P):
            ans += 1 k itertools.combinations(range(1, N + 1), i) itertools.combinations itertools combinations range(1, N + 1) range 1 N + 1 N 1 i if hantei(A, k, P):
            ans += 1 hantei(A, k, P) hantei A k P ans += 1 ans 1 if hantei(A, [0], P):
    ans += 1 hantei(A, [0], P) hantei A [0] 0 P ans += 1 ans 1 print(ans) print ans ans += 1 1 ans N, M = map(int, input().split()) map(int, input().split()) N ans = 0 0 ans P = tuple(map(int, input().split())) tuple(map(int, input().split())) P ans += 1 1 ans A = [] [] A def hantei(A, RETU, P):
    for i in range(len(A)):
        count = 0
        for k in RETU:
            if k in A[i][1:]:
                count += 1
        if not count % 2 == P[i]:
            return False
    return True def hantei(A, RETU, P):
    for i in range(len(A)):
        count = 0
        for k in RETU:
            if k in A[i][1:]:
                count += 1
        if not count % 2 == P[i]:
            return False
    return True hantei M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append(tuple(map(int, input().split())))
P = tuple(map(int, input().split()))
import itertools
def hantei(A, RETU, P):
    for i in range(len(A)):
        count = 0
        for k in RETU:
            if k in A[i][1:]:
                count += 1
        if not count % 2 == P[i]:
            return False
    return True
ans = 0
for i in range(1, N + 1):
    for k in itertools.combinations(range(1, N + 1), i):
        if hantei(A, k, P):
            ans += 1
if hantei(A, [0], P):
    ans += 1
print(ans)