import copy

n, m = list(map(int, input().split()))
s = []

for i in range(m):
    st = list(map(int, input().split()))
    s.append([0]+st)


p = list(map(int, input().split()))
ans = 0

# 全bit探索
for i in range(2**(n)):
    lst = copy.deepcopy(s) # list のコピーにはcopy.copy()を用いる(2重配列以上はdeepcopy()を用いる)
    flag = True
    for j in range(n):
        if i >> j & 1 == 1:
            for k in lst:
                for l in range(2, k[1]+2):
                    if k[l]-1 == j:
                        k[0] += 1
    # 偶数奇数が合えば ans+=1
    for b in range(len(p)):
        if p[b] != lst[b][0]%2:
            flag = False
    if flag == True:
        ans +=1

print(ans) import copy copy 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 s = [] s [] for i in range(m):
    st = list(map(int, input().split()))
    s.append([0]+st) i range(m) range m st = list(map(int, input().split())) st list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split s.append([0]+st) s.append s append [0]+st [0] 0 st 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 i in range(2**(n)):
    lst = copy.deepcopy(s) # list のコピーにはcopy.copy()を用いる(2重配列以上はdeepcopy()を用いる)
    flag = True
    for j in range(n):
        if i >> j & 1 == 1:
            for k in lst:
                for l in range(2, k[1]+2):
                    if k[l]-1 == j:
                        k[0] += 1
    # 偶数奇数が合えば ans+=1
    for b in range(len(p)):
        if p[b] != lst[b][0]%2:
            flag = False
    if flag == True:
        ans +=1 i range(2**(n)) range 2**(n) 2 n lst = copy.deepcopy(s) lst copy.deepcopy(s) copy.deepcopy copy deepcopy s flag = True flag True for j in range(n):
        if i >> j & 1 == 1:
            for k in lst:
                for l in range(2, k[1]+2):
                    if k[l]-1 == j:
                        k[0] += 1
    # 偶数奇数が合えば ans+=1
     j range(n) range n if i >> j & 1 == 1:
            for k in lst:
                for l in range(2, k[1]+2):
                    if k[l]-1 == j:
                        k[0] += 1
    # 偶数奇数が合えば ans+=1
     i >> j & 1 == 1 i >> j & 1 i >> j i j 1 1 for k in lst:
                for l in range(2, k[1]+2):
                    if k[l]-1 == j:
                        k[0] += 1
    # 偶数奇数が合えば ans+=1
     k lst for l in range(2, k[1]+2):
                    if k[l]-1 == j:
                        k[0] += 1
    # 偶数奇数が合えば ans+=1
     l range(2, k[1]+2) range 2 k[1]+2 k[1] k 1 2 if k[l]-1 == j:
                        k[0] += 1
    # 偶数奇数が合えば ans+=1
     k[l]-1 == j k[l]-1 k[l] k l 1 j k[0] += 1 k[0] k 0 1 for b in range(len(p)):
        if p[b] != lst[b][0]%2:
            flag = False
     b range(len(p)) range len(p) len p if p[b] != lst[b][0]%2:
            flag = False
     p[b] != lst[b][0]%2 p[b] p b lst[b][0]%2 lst[b][0] [b] lst b 0 2 flag = False flag False if flag == True:
        ans +=1 flag == True flag True ans +=1 ans 1 print(ans) print ans n, m = list(map(int, input().split())) list(map(int, input().split())) n flag = True True flag st = list(map(int, input().split())) list(map(int, input().split())) st ans = 0 0 ans p = list(map(int, input().split())) list(map(int, input().split())) p flag = False False flag s = [] [] s ans +=1 1 ans m = list(map(int, input().split())) list(map(int, input().split())) m lst = copy.deepcopy(s) copy.deepcopy(s) lst
import copy

n, m = list(map(int, input().split()))
s = []

for i in range(m):
    st = list(map(int, input().split()))
    s.append([0]+st)


p = list(map(int, input().split()))
ans = 0

# 全bit探索
for i in range(2**(n)):
    lst = copy.deepcopy(s) # list のコピーにはcopy.copy()を用いる(2重配列以上はdeepcopy()を用いる)
    flag = True
    for j in range(n):
        if i >> j & 1 == 1:
            for k in lst:
                for l in range(2, k[1]+2):
                    if k[l]-1 == j:
                        k[0] += 1
    # 偶数奇数が合えば ans+=1
    for b in range(len(p)):
        if p[b] != lst[b][0]%2:
            flag = False
    if flag == True:
        ans +=1

print(ans)