
n, m = map(int, input().split(' '))
k = []
s = []
for i in range(m):
    a = list(map(int, input().split(' ')))
    k.append(a[0])
    s.append(a[1:])
p = list(map(int, input().split(' ')))
ans = 0
for i in range(2**n):
    ri_cnt = 0
    for j in range(m):
        sw_cnt = 0
        for l in range(k[j]):
            if (i >> (s[j][l]-1)) & 1:
                sw_cnt += 1
        if sw_cnt % 2 == p[j]:
            ri_cnt += 1
    if ri_cnt == m:
        ans += 1
print(ans) n, m = map(int, input().split(' ')) n map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' m k = [] k [] s = [] s [] for i in range(m):
    a = list(map(int, input().split(' ')))
    k.append(a[0])
    s.append(a[1:]) i range(m) range m a = list(map(int, input().split(' '))) a list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' k.append(a[0]) k.append k append a[0] a 0 s.append(a[1:]) s.append s append a[1:] a 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 ' ' ans = 0 ans 0 for i in range(2**n):
    ri_cnt = 0
    for j in range(m):
        sw_cnt = 0
        for l in range(k[j]):
            if (i >> (s[j][l]-1)) & 1:
                sw_cnt += 1
        if sw_cnt % 2 == p[j]:
            ri_cnt += 1
    if ri_cnt == m:
        ans += 1 i range(2**n) range 2**n 2 n ri_cnt = 0 ri_cnt 0 for j in range(m):
        sw_cnt = 0
        for l in range(k[j]):
            if (i >> (s[j][l]-1)) & 1:
                sw_cnt += 1
        if sw_cnt % 2 == p[j]:
            ri_cnt += 1
     j range(m) range m sw_cnt = 0 sw_cnt 0 for l in range(k[j]):
            if (i >> (s[j][l]-1)) & 1:
                sw_cnt += 1
         l range(k[j]) range k[j] k j if (i >> (s[j][l]-1)) & 1:
                sw_cnt += 1
         (i >> (s[j][l]-1)) & 1 i >> (s[j][l]-1) i s[j][l]-1 s[j][l] [j] s j l 1 1 sw_cnt += 1 sw_cnt 1 if sw_cnt % 2 == p[j]:
            ri_cnt += 1
     sw_cnt % 2 == p[j] sw_cnt % 2 sw_cnt 2 p[j] p j ri_cnt += 1 ri_cnt 1 if ri_cnt == m:
        ans += 1 ri_cnt == m ri_cnt m ans += 1 ans 1 print(ans) print ans ans = 0 0 ans ri_cnt = 0 0 ri_cnt p = list(map(int, input().split(' '))) list(map(int, input().split(' '))) p m = map(int, input().split(' ')) map(int, input().split(' ')) m a = list(map(int, input().split(' '))) list(map(int, input().split(' '))) a ri_cnt += 1 1 ri_cnt n, m = map(int, input().split(' ')) map(int, input().split(' ')) n k = [] [] k sw_cnt = 0 0 sw_cnt sw_cnt += 1 1 sw_cnt s = [] [] s ans += 1 1 ans

n, m = map(int, input().split(' '))
k = []
s = []
for i in range(m):
    a = list(map(int, input().split(' ')))
    k.append(a[0])
    s.append(a[1:])
p = list(map(int, input().split(' ')))
ans = 0
for i in range(2**n):
    ri_cnt = 0
    for j in range(m):
        sw_cnt = 0
        for l in range(k[j]):
            if (i >> (s[j][l]-1)) & 1:
                sw_cnt += 1
        if sw_cnt % 2 == p[j]:
            ri_cnt += 1
    if ri_cnt == m:
        ans += 1
print(ans)
