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