import itertools

n,m = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))

#onにするスイッチを選ぶ
switch = [i for i in range(1,n+1)]
comb = []
for i in range(n+1):
    for v in itertools.combinations(switch,i):
        comb.append(v)

ans = 0
for i in comb:
    for j in range(m):
        tmp = 0
        for l in range(1,ks[j][0]+1):
            if ks[j][l] in i:
                tmp += 1
        if tmp%2 != p[j]:
            break
    else:
        ans += 1

print(ans) import itertools itertools n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m list(map(int,input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ks = [list(map(int,input().split())) for i in range(m)] ks [list(map(int,input().split())) for i in range(m)] p = list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split i for i in range(1,n+1) for i in range(1,n+1) i range(1,n+1) range 1 n+1 n 1 for i in range(1,n+1) i switch = [i for i in range(1,n+1)] switch [i for i in range(1,n+1)] comb = [] comb [] for i in range(n+1):
    for v in itertools.combinations(switch,i):
        comb.append(v) i range(n+1) range n+1 n 1 for v in itertools.combinations(switch,i):
        comb.append(v) v itertools.combinations(switch,i) itertools.combinations itertools combinations switch i comb.append(v) comb.append comb append v ans = 0 ans 0 for i in comb:
    for j in range(m):
        tmp = 0
        for l in range(1,ks[j][0]+1):
            if ks[j][l] in i:
                tmp += 1
        if tmp%2 != p[j]:
            break
    else:
        ans += 1 i comb for j in range(m):
        tmp = 0
        for l in range(1,ks[j][0]+1):
            if ks[j][l] in i:
                tmp += 1
        if tmp%2 != p[j]:
            break
    else:
        ans += 1 j range(m) range m tmp = 0 tmp 0 for l in range(1,ks[j][0]+1):
            if ks[j][l] in i:
                tmp += 1
         l range(1,ks[j][0]+1) range 1 ks[j][0]+1 ks[j][0] [j] ks j 0 1 if ks[j][l] in i:
                tmp += 1
         ks[j][l] in i ks[j][l] [j] ks j l i tmp += 1 tmp 1 if tmp%2 != p[j]:
            break
     tmp%2 != p[j] tmp%2 tmp 2 p[j] p j break ans += 1 ans 1 print(ans) print ans p = list(map(int,input().split())) list(map(int,input().split())) p n,m = map(int,input().split()) map(int,input().split()) n tmp = 0 0 tmp switch = [i for i in range(1,n+1)] [i for i in range(1,n+1)] switch ans += 1 1 ans m = map(int,input().split()) map(int,input().split()) m comb = [] [] comb ans = 0 0 ans ks = [list(map(int,input().split())) for i in range(m)] [list(map(int,input().split())) for i in range(m)] ks tmp += 1 1 tmp
import itertools

n,m = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))

#onにするスイッチを選ぶ
switch = [i for i in range(1,n+1)]
comb = []
for i in range(n+1):
    for v in itertools.combinations(switch,i):
        comb.append(v)

ans = 0
for i in comb:
    for j in range(m):
        tmp = 0
        for l in range(1,ks[j][0]+1):
            if ks[j][l] in i:
                tmp += 1
        if tmp%2 != p[j]:
            break
    else:
        ans += 1

print(ans)