import math
import itertools

n, m = map(int, input().split(" "))
sL = []
for i in range(m):
    _, *s = map(int, input().split(" "))
    sL.append(s)
pL = list(map(int, input().split(" ")))

bz = list(itertools.product([0, 1], repeat=n))
ans = 0
for b1 in bz:
    for i in range(m):
        s = sL[i]
        p = pL[i]
        cnt = 0
        for si in s:
            if b1[si - 1] == 1:
                cnt += 1
        if cnt % 2 != p:
            break
    else:
        ans += 1

print(ans) import math math import itertools itertools n, m = map(int, input().split(" ")) n map(int, input().split(" ")) map int input().split(" ") ().split () input split " " m sL = [] sL [] for i in range(m):
    _, *s = map(int, input().split(" "))
    sL.append(s) i range(m) range m _, *s = map(int, input().split(" ")) _ map(int, input().split(" ")) map int input().split(" ") ().split () input split " " *s s sL.append(s) sL.append sL append s pL = list(map(int, input().split(" "))) pL list(map(int, input().split(" "))) list map(int, input().split(" ")) map int input().split(" ") ().split () input split " " bz = list(itertools.product([0, 1], repeat=n)) bz list(itertools.product([0, 1], repeat=n)) list itertools.product([0, 1], repeat=n) itertools.product itertools product [0, 1] 0 1 repeat=n repeat n ans = 0 ans 0 for b1 in bz:
    for i in range(m):
        s = sL[i]
        p = pL[i]
        cnt = 0
        for si in s:
            if b1[si - 1] == 1:
                cnt += 1
        if cnt % 2 != p:
            break
    else:
        ans += 1 b1 bz for i in range(m):
        s = sL[i]
        p = pL[i]
        cnt = 0
        for si in s:
            if b1[si - 1] == 1:
                cnt += 1
        if cnt % 2 != p:
            break
    else:
        ans += 1 i range(m) range m s = sL[i] s sL[i] sL i p = pL[i] p pL[i] pL i cnt = 0 cnt 0 for si in s:
            if b1[si - 1] == 1:
                cnt += 1
         si s if b1[si - 1] == 1:
                cnt += 1
         b1[si - 1] == 1 b1[si - 1] b1 si - 1 si 1 1 cnt += 1 cnt 1 if cnt % 2 != p:
            break
     cnt % 2 != p cnt % 2 cnt 2 p break ans += 1 ans 1 print(ans) print ans ans = 0 0 ans p = pL[i] pL[i] p n, m = map(int, input().split(" ")) map(int, input().split(" ")) n m = map(int, input().split(" ")) map(int, input().split(" ")) m s = sL[i] sL[i] s pL = list(map(int, input().split(" "))) list(map(int, input().split(" "))) pL cnt += 1 1 cnt ans += 1 1 ans sL = [] [] sL cnt = 0 0 cnt _, *s = map(int, input().split(" ")) map(int, input().split(" ")) _ bz = list(itertools.product([0, 1], repeat=n)) list(itertools.product([0, 1], repeat=n)) bz
import math
import itertools

n, m = map(int, input().split(" "))
sL = []
for i in range(m):
    _, *s = map(int, input().split(" "))
    sL.append(s)
pL = list(map(int, input().split(" ")))

bz = list(itertools.product([0, 1], repeat=n))
ans = 0
for b1 in bz:
    for i in range(m):
        s = sL[i]
        p = pL[i]
        cnt = 0
        for si in s:
            if b1[si - 1] == 1:
                cnt += 1
        if cnt % 2 != p:
            break
    else:
        ans += 1

print(ans)
