import itertools
n,m = map(int,input().split())
k = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
s = []
for i in range(n):
    s.append(i)
count = 0
for i in range(n+1):
    for item in itertools.combinations(s, i):
        li = [0] * m
        onoff = [0]*n
        for j in item:
            onoff[j] = 1
        for k_i in range(m):
            c = 0
            for k_j in range(k[k_i][0]):
                if onoff[k[k_i][k_j+1]-1] == 1:
                    c += 1
            if c % 2 == p[k_i]:
                li[k_i] = 1
        if all(li):
            count += 1
print(count) 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 _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k = [list(map(int,input().split())) for _ in range(m)] k [list(map(int,input().split())) for _ 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 s = [] s [] for i in range(n):
    s.append(i) i range(n) range n s.append(i) s.append s append i count = 0 count 0 for i in range(n+1):
    for item in itertools.combinations(s, i):
        li = [0] * m
        onoff = [0]*n
        for j in item:
            onoff[j] = 1
        for k_i in range(m):
            c = 0
            for k_j in range(k[k_i][0]):
                if onoff[k[k_i][k_j+1]-1] == 1:
                    c += 1
            if c % 2 == p[k_i]:
                li[k_i] = 1
        if all(li):
            count += 1 i range(n+1) range n+1 n 1 for item in itertools.combinations(s, i):
        li = [0] * m
        onoff = [0]*n
        for j in item:
            onoff[j] = 1
        for k_i in range(m):
            c = 0
            for k_j in range(k[k_i][0]):
                if onoff[k[k_i][k_j+1]-1] == 1:
                    c += 1
            if c % 2 == p[k_i]:
                li[k_i] = 1
        if all(li):
            count += 1 item itertools.combinations(s, i) itertools.combinations itertools combinations s i li = [0] * m li [0] * m [0] 0 m onoff = [0]*n onoff [0]*n [0] 0 n for j in item:
            onoff[j] = 1
         j item onoff[j] = 1 onoff[j] onoff j 1 for k_i in range(m):
            c = 0
            for k_j in range(k[k_i][0]):
                if onoff[k[k_i][k_j+1]-1] == 1:
                    c += 1
            if c % 2 == p[k_i]:
                li[k_i] = 1
         k_i range(m) range m c = 0 c 0 for k_j in range(k[k_i][0]):
                if onoff[k[k_i][k_j+1]-1] == 1:
                    c += 1
             k_j range(k[k_i][0]) range k[k_i][0] [k_i] k k_i 0 if onoff[k[k_i][k_j+1]-1] == 1:
                    c += 1
             onoff[k[k_i][k_j+1]-1] == 1 onoff[k[k_i][k_j+1]-1] onoff k[k_i][k_j+1]-1 k[k_i][k_j+1] [k_i] k k_i k_j+1 k_j 1 1 1 c += 1 c 1 if c % 2 == p[k_i]:
                li[k_i] = 1
         c % 2 == p[k_i] c % 2 c 2 p[k_i] p k_i li[k_i] = 1 li[k_i] li k_i 1 if all(li):
            count += 1 all(li) all li count += 1 count 1 print(count) print count s = [] [] s count = 0 0 count c += 1 1 c n,m = map(int,input().split()) map(int,input().split()) n p = list(map(int,input().split())) list(map(int,input().split())) p onoff = [0]*n [0]*n onoff count += 1 1 count m = map(int,input().split()) map(int,input().split()) m k = [list(map(int,input().split())) for _ in range(m)] [list(map(int,input().split())) for _ in range(m)] k li = [0] * m [0] * m li c = 0 0 c
import itertools
n,m = map(int,input().split())
k = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
s = []
for i in range(n):
    s.append(i)
count = 0
for i in range(n+1):
    for item in itertools.combinations(s, i):
        li = [0] * m
        onoff = [0]*n
        for j in item:
            onoff[j] = 1
        for k_i in range(m):
            c = 0
            for k_j in range(k[k_i][0]):
                if onoff[k[k_i][k_j+1]-1] == 1:
                    c += 1
            if c % 2 == p[k_i]:
                li[k_i] = 1
        if all(li):
            count += 1
print(count)