n,m=map(int,input().split())
k = [0]*m
s = [0]*m

for i in range(m):
    k[i], *s[i] = map(int,input().split())

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

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

for i in range(m):
    k[i], *s[i] = map(int,input().split())

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

ans = 0
for i in range(1 << n):
    cnt = [0]*m
    for j in range(n):
        if (i >> j) % 2 == 1:
            for a in range(m):
                if j + 1 in s[a]:
                    cnt[a] += 1
    chk = 0
    for j in range(m):
        if cnt[j] % 2 != p[j]:
            chk = 1
            break
    if chk == 0:
        ans += 1
print(ans)