from itertools import product
from copy import deepcopy

n, m = map(int, input().split())
k = []
s = []
for j in range(m):
    a = list(map(int, input().split()))
    k.append(a[0])
    s.append(deepcopy(a[1:]))
p = list(map(int, input().split()))

ans = 0
for x in product([0,1], repeat=n):
    c = True
    for i in range(m):
        count = 0
        for j in range(k[i]):
            if x[s[i][j]-1] == 1:
                count += 1
        if count % 2 != p[i]:
            c = False
            break
    if c:
        ans += 1
print(ans) from itertools import product from copy import deepcopy n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m k = [] k [] s = [] s [] for j in range(m):
    a = list(map(int, input().split()))
    k.append(a[0])
    s.append(deepcopy(a[1:])) j range(m) range m a = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k.append(a[0]) k.append k append a[0] a 0 s.append(deepcopy(a[1:])) s.append s append deepcopy(a[1:]) deepcopy a[1:] a 1: 1 p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for x in product([0,1], repeat=n):
    c = True
    for i in range(m):
        count = 0
        for j in range(k[i]):
            if x[s[i][j]-1] == 1:
                count += 1
        if count % 2 != p[i]:
            c = False
            break
    if c:
        ans += 1 x product([0,1], repeat=n) product [0,1] 0 1 repeat=n repeat n c = True c True for i in range(m):
        count = 0
        for j in range(k[i]):
            if x[s[i][j]-1] == 1:
                count += 1
        if count % 2 != p[i]:
            c = False
            break
     i range(m) range m count = 0 count 0 for j in range(k[i]):
            if x[s[i][j]-1] == 1:
                count += 1
         j range(k[i]) range k[i] k i if x[s[i][j]-1] == 1:
                count += 1
         x[s[i][j]-1] == 1 x[s[i][j]-1] x s[i][j]-1 s[i][j] [i] s i j 1 1 count += 1 count 1 if count % 2 != p[i]:
            c = False
            break
     count % 2 != p[i] count % 2 count 2 p[i] p i c = False c False break if c:
        ans += 1 c ans += 1 ans 1 print(ans) print ans count = 0 0 count n, m = map(int, input().split()) map(int, input().split()) n p = list(map(int, input().split())) list(map(int, input().split())) p ans += 1 1 ans k = [] [] k s = [] [] s c = True True c a = list(map(int, input().split())) list(map(int, input().split())) a count += 1 1 count ans = 0 0 ans c = False False c m = map(int, input().split()) map(int, input().split()) m
from itertools import product
from copy import deepcopy

n, m = map(int, input().split())
k = []
s = []
for j in range(m):
    a = list(map(int, input().split()))
    k.append(a[0])
    s.append(deepcopy(a[1:]))
p = list(map(int, input().split()))

ans = 0
for x in product([0,1], repeat=n):
    c = True
    for i in range(m):
        count = 0
        for j in range(k[i]):
            if x[s[i][j]-1] == 1:
                count += 1
        if count % 2 != p[i]:
            c = False
            break
    if c:
        ans += 1
print(ans)