from itertools import product
n, m = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(m)]
pl = list(map(int, input().split()))
ans = 0
for bits in product([0, 1], repeat=n):
    flag = True
    for i, ss in enumerate(s):
        cnt = 0
        for sss in ss[1:]:
            if bits[sss-1] == 1:
                cnt += 1
        if not cnt % 2 == pl[i]:
            flag = False
    if flag:
        ans += 1
print(ans) from itertools import product n, m = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split m list(map(int, input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split s = [list(map(int, input().split())) for i in range(m)] s [list(map(int, input().split())) for i in range(m)] pl = list(map(int, input().split())) pl list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for bits in product([0, 1], repeat=n):
    flag = True
    for i, ss in enumerate(s):
        cnt = 0
        for sss in ss[1:]:
            if bits[sss-1] == 1:
                cnt += 1
        if not cnt % 2 == pl[i]:
            flag = False
    if flag:
        ans += 1 bits product([0, 1], repeat=n) product [0, 1] 0 1 repeat=n repeat n flag = True flag True for i, ss in enumerate(s):
        cnt = 0
        for sss in ss[1:]:
            if bits[sss-1] == 1:
                cnt += 1
        if not cnt % 2 == pl[i]:
            flag = False
     i ss enumerate(s) enumerate s cnt = 0 cnt 0 for sss in ss[1:]:
            if bits[sss-1] == 1:
                cnt += 1
         sss ss[1:] ss 1: 1 if bits[sss-1] == 1:
                cnt += 1
         bits[sss-1] == 1 bits[sss-1] bits sss-1 sss 1 1 cnt += 1 cnt 1 if not cnt % 2 == pl[i]:
            flag = False
     not cnt % 2 == pl[i] cnt % 2 == pl[i] cnt % 2 cnt 2 pl[i] pl i flag = False flag False if flag:
        ans += 1 flag ans += 1 ans 1 print(ans) print ans cnt += 1 1 cnt s = [list(map(int, input().split())) for i in range(m)] [list(map(int, input().split())) for i in range(m)] s ans = 0 0 ans n, m = list(map(int, input().split())) list(map(int, input().split())) n cnt = 0 0 cnt m = list(map(int, input().split())) list(map(int, input().split())) m flag = False False flag ans += 1 1 ans pl = list(map(int, input().split())) list(map(int, input().split())) pl flag = True True flag
from itertools import product
n, m = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(m)]
pl = list(map(int, input().split()))
ans = 0
for bits in product([0, 1], repeat=n):
    flag = True
    for i, ss in enumerate(s):
        cnt = 0
        for sss in ss[1:]:
            if bits[sss-1] == 1:
                cnt += 1
        if not cnt % 2 == pl[i]:
            flag = False
    if flag:
        ans += 1
print(ans)
