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(1<<N):
    ri_count = 0
    for j in range(M):
        sw_count = 0
        for l in range(k[j]):
            if i>>(s[j][l]-1) & 1:
                sw_count += 1
        if sw_count%2 == p[j]:
            ri_count += 1
    if ri_count == 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(1<<N):
    ri_count = 0
    for j in range(M):
        sw_count = 0
        for l in range(k[j]):
            if i>>(s[j][l]-1) & 1:
                sw_count += 1
        if sw_count%2 == p[j]:
            ri_count += 1
    if ri_count == M:
        ans += 1 i range(1<<N) range 1<<N 1 N ri_count = 0 ri_count 0 for j in range(M):
        sw_count = 0
        for l in range(k[j]):
            if i>>(s[j][l]-1) & 1:
                sw_count += 1
        if sw_count%2 == p[j]:
            ri_count += 1
     j range(M) range M sw_count = 0 sw_count 0 for l in range(k[j]):
            if i>>(s[j][l]-1) & 1:
                sw_count += 1
         l range(k[j]) range k[j] k j if i>>(s[j][l]-1) & 1:
                sw_count += 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_count += 1 sw_count 1 if sw_count%2 == p[j]:
            ri_count += 1
     sw_count%2 == p[j] sw_count%2 sw_count 2 p[j] p j ri_count += 1 ri_count 1 if ri_count == M:
        ans += 1 ri_count == M ri_count M ans += 1 ans 1 print(ans) print ans N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M k = [] [] k s = [] [] s ri_count += 1 1 ri_count ans += 1 1 ans p = list(map(int, input().split())) list(map(int, input().split())) p a = list(map(int, input().split())) list(map(int, input().split())) a sw_count = 0 0 sw_count ans = 0 0 ans ri_count = 0 0 ri_count sw_count += 1 1 sw_count
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(1<<N):
    ri_count = 0
    for j in range(M):
        sw_count = 0
        for l in range(k[j]):
            if i>>(s[j][l]-1) & 1:
                sw_count += 1
        if sw_count%2 == p[j]:
            ri_count += 1
    if ri_count == M:
        ans += 1
print(ans)
