from itertools import product

n, m = map(int, input().split())
switches = []
for _ in range(m):
    x = list(map(int, input().split()))[1:]
    temp = []
    for i in range(n):
        if i + 1 in x:
            temp.append(1)
        else:
            temp.append(0)
    switches.append(temp)
p = list(map(int, input().split()))

ans = 0
for on_off in product([1, 0], repeat=n):
    flag = 1
    for i, switch in enumerate(switches):
        cnt = 0
        for x, y in zip(on_off, switch):
            if x == 1 and y == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            flag = 0
    if flag:
        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 switches = [] switches [] for _ in range(m):
    x = list(map(int, input().split()))[1:]
    temp = []
    for i in range(n):
        if i + 1 in x:
            temp.append(1)
        else:
            temp.append(0)
    switches.append(temp) _ range(m) range m x = list(map(int, input().split()))[1:] x list(map(int, input().split()))[1:] (map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 1: 1 temp = [] temp [] for i in range(n):
        if i + 1 in x:
            temp.append(1)
        else:
            temp.append(0)
     i range(n) range n if i + 1 in x:
            temp.append(1)
        else:
            temp.append(0)
     i + 1 in x i + 1 i 1 x temp.append(1) temp.append temp append 1 temp.append(0) temp.append temp append 0 switches.append(temp) switches.append switches append temp 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 on_off in product([1, 0], repeat=n):
    flag = 1
    for i, switch in enumerate(switches):
        cnt = 0
        for x, y in zip(on_off, switch):
            if x == 1 and y == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            flag = 0
    if flag:
        ans += 1 on_off product([1, 0], repeat=n) product [1, 0] 1 0 repeat=n repeat n flag = 1 flag 1 for i, switch in enumerate(switches):
        cnt = 0
        for x, y in zip(on_off, switch):
            if x == 1 and y == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            flag = 0
     i switch enumerate(switches) enumerate switches cnt = 0 cnt 0 for x, y in zip(on_off, switch):
            if x == 1 and y == 1:
                cnt += 1
         x y zip(on_off, switch) zip on_off switch if x == 1 and y == 1:
                cnt += 1
         x == 1 and y == 1 x == 1 x 1 y == 1 y 1 cnt += 1 cnt 1 if cnt % 2 != p[i]:
            flag = 0
     cnt % 2 != p[i] cnt % 2 cnt 2 p[i] p i flag = 0 flag 0 if flag:
        ans += 1 flag ans += 1 ans 1 print(ans) print ans n, m = map(int, input().split()) map(int, input().split()) n ans = 0 0 ans switches = [] [] switches p = list(map(int, input().split())) list(map(int, input().split())) p flag = 1 1 flag x = list(map(int, input().split()))[1:] list(map(int, input().split()))[1:] x ans += 1 1 ans temp = [] [] temp cnt = 0 0 cnt flag = 0 0 flag m = map(int, input().split()) map(int, input().split()) m cnt += 1 1 cnt
from itertools import product

n, m = map(int, input().split())
switches = []
for _ in range(m):
    x = list(map(int, input().split()))[1:]
    temp = []
    for i in range(n):
        if i + 1 in x:
            temp.append(1)
        else:
            temp.append(0)
    switches.append(temp)
p = list(map(int, input().split()))

ans = 0
for on_off in product([1, 0], repeat=n):
    flag = 1
    for i, switch in enumerate(switches):
        cnt = 0
        for x, y in zip(on_off, switch):
            if x == 1 and y == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            flag = 0
    if flag:
        ans += 1

print(ans)