from itertools import combinations
n,m = map(int,input().split())
l = []
for i in range(m):
    u = list(map(int,input().split()))
    u = u[1:]
    l.append(u)

p = list(map(int,input().split()))
v = []
for i in range(1,n+1):
    v.append(i)

c = []
for i in range(n+1):
    a = combinations(v,i)
    for k in a:
        c.append(k)

ans = 0
for ele in c:
    s = set(ele)
    f = 0
    for i in range(len(l)):
        x = l[i]
        cnt = 0
        for j in x:
            if j in s:
                cnt = cnt+1

        if cnt%2 != p[i]:
            f = 1
            break

    if f == 0:
        ans = ans+1

print(ans) from itertools import combinations 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):
    u = list(map(int,input().split()))
    u = u[1:]
    l.append(u) i range(m) range m u = list(map(int,input().split())) u list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split u = u[1:] u u[1:] u 1: 1 l.append(u) l.append l append u p = list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split v = [] v [] for i in range(1,n+1):
    v.append(i) i range(1,n+1) range 1 n+1 n 1 v.append(i) v.append v append i c = [] c [] for i in range(n+1):
    a = combinations(v,i)
    for k in a:
        c.append(k) i range(n+1) range n+1 n 1 a = combinations(v,i) a combinations(v,i) combinations v i for k in a:
        c.append(k) k a c.append(k) c.append c append k ans = 0 ans 0 for ele in c:
    s = set(ele)
    f = 0
    for i in range(len(l)):
        x = l[i]
        cnt = 0
        for j in x:
            if j in s:
                cnt = cnt+1

        if cnt%2 != p[i]:
            f = 1
            break

    if f == 0:
        ans = ans+1 ele c s = set(ele) s set(ele) set ele f = 0 f 0 for i in range(len(l)):
        x = l[i]
        cnt = 0
        for j in x:
            if j in s:
                cnt = cnt+1

        if cnt%2 != p[i]:
            f = 1
            break

     i range(len(l)) range len(l) len l x = l[i] x l[i] l i cnt = 0 cnt 0 for j in x:
            if j in s:
                cnt = cnt+1

         j x if j in s:
                cnt = cnt+1

         j in s j s cnt = cnt+1 cnt cnt+1 cnt 1 if cnt%2 != p[i]:
            f = 1
            break

     cnt%2 != p[i] cnt%2 cnt 2 p[i] p i f = 1 f 1 break if f == 0:
        ans = ans+1 f == 0 f 0 ans = ans+1 ans ans+1 ans 1 print(ans) print ans u = u[1:] u[1:] u p = list(map(int,input().split())) list(map(int,input().split())) p c = [] [] c s = set(ele) set(ele) s a = combinations(v,i) combinations(v,i) a ans = 0 0 ans f = 1 1 f x = l[i] l[i] x cnt = cnt+1 cnt+1 cnt cnt = 0 0 cnt n,m = map(int,input().split()) map(int,input().split()) n f = 0 0 f ans = ans+1 ans+1 ans l = [] [] l m = map(int,input().split()) map(int,input().split()) m u = list(map(int,input().split())) list(map(int,input().split())) u v = [] [] v
from itertools import combinations
n,m = map(int,input().split())
l = []
for i in range(m):
    u = list(map(int,input().split()))
    u = u[1:]
    l.append(u)

p = list(map(int,input().split()))
v = []
for i in range(1,n+1):
    v.append(i)

c = []
for i in range(n+1):
    a = combinations(v,i)
    for k in a:
        c.append(k)

ans = 0
for ele in c:
    s = set(ele)
    f = 0
    for i in range(len(l)):
        x = l[i]
        cnt = 0
        for j in x:
            if j in s:
                cnt = cnt+1

        if cnt%2 != p[i]:
            f = 1
            break

    if f == 0:
        ans = ans+1

print(ans)