from itertools import product

N, M = map(int, input().split())
k = []
S = []
for _ in range(M):
    ks = list(map(int, input().split()))
    k.append(ks[0])
    S.append(ks[1:])
p = list(map(int, input().split()))

onoff = list(product([0, 1], repeat = N))

ans = 0
for i in onoff:
    cnt = 0
    for ind, s in enumerate(S):
        state = 0
        for o in s:
            state += i[o-1]
        if state % 2 == p[ind]:
            cnt += 1
    if cnt == M:
        ans += 1

print(ans) from itertools import product N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M k = [] k [] S = [] S [] for _ in range(M):
    ks = list(map(int, input().split()))
    k.append(ks[0])
    S.append(ks[1:]) _ range(M) range M ks = list(map(int, input().split())) ks list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k.append(ks[0]) k.append k append ks[0] ks 0 S.append(ks[1:]) S.append S append ks[1:] ks 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 onoff = list(product([0, 1], repeat = N)) onoff list(product([0, 1], repeat = N)) list product([0, 1], repeat = N) product [0, 1] 0 1 repeat = N repeat N ans = 0 ans 0 for i in onoff:
    cnt = 0
    for ind, s in enumerate(S):
        state = 0
        for o in s:
            state += i[o-1]
        if state % 2 == p[ind]:
            cnt += 1
    if cnt == M:
        ans += 1 i onoff cnt = 0 cnt 0 for ind, s in enumerate(S):
        state = 0
        for o in s:
            state += i[o-1]
        if state % 2 == p[ind]:
            cnt += 1
     ind s enumerate(S) enumerate S state = 0 state 0 for o in s:
            state += i[o-1]
         o s state += i[o-1] state i[o-1] i o-1 o 1 if state % 2 == p[ind]:
            cnt += 1
     state % 2 == p[ind] state % 2 state 2 p[ind] p ind cnt += 1 cnt 1 if cnt == M:
        ans += 1 cnt == M cnt M ans += 1 ans 1 print(ans) print ans p = list(map(int, input().split())) list(map(int, input().split())) p N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M S = [] [] S ans += 1 1 ans state = 0 0 state state += i[o-1] i[o-1] state ks = list(map(int, input().split())) list(map(int, input().split())) ks cnt += 1 1 cnt k = [] [] k onoff = list(product([0, 1], repeat = N)) list(product([0, 1], repeat = N)) onoff ans = 0 0 ans cnt = 0 0 cnt
from itertools import product

N, M = map(int, input().split())
k = []
S = []
for _ in range(M):
    ks = list(map(int, input().split()))
    k.append(ks[0])
    S.append(ks[1:])
p = list(map(int, input().split()))

onoff = list(product([0, 1], repeat = N))

ans = 0
for i in onoff:
    cnt = 0
    for ind, s in enumerate(S):
        state = 0
        for o in s:
            state += i[o-1]
        if state % 2 == p[ind]:
            cnt += 1
    if cnt == M:
        ans += 1

print(ans)
