import copy
N,M = map(int,input().split())
num = {}
tmp ={}
tmpli = []
li = []
p = []
count = 0
for i in range(M):
    for i in range(N):
        num[i+1] = 0
    a = list(map(int,input().split()))
    for j in range(len(a)-1):
        if a[j+1] in num:
            num[a[j+1]] += 1
    li.append(num.copy())
p = list(map(int,input().split()))

for i in range(2**N):
    tmpli = copy.deepcopy(li)
    for j in range(N):
        if ((i >> j) & 1):
            for k in tmpli:
                if j + 1 in k:
                    k[j+1] = 0
    tmp = 0
    for b in range(len(p)):
        if sum(tmpli[b].values()) % 2 == p[b]:
            tmp += 1
    if tmp == len(p):
        count += 1
print(count) import copy copy N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M num = {} num {} tmp ={} tmp {} tmpli = [] tmpli [] li = [] li [] p = [] p [] count = 0 count 0 for i in range(M):
    for i in range(N):
        num[i+1] = 0
    a = list(map(int,input().split()))
    for j in range(len(a)-1):
        if a[j+1] in num:
            num[a[j+1]] += 1
    li.append(num.copy()) i range(M) range M for i in range(N):
        num[i+1] = 0
     i range(N) range N num[i+1] = 0 num[i+1] num i+1 i 1 0 a = list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for j in range(len(a)-1):
        if a[j+1] in num:
            num[a[j+1]] += 1
     j range(len(a)-1) range len(a)-1 len(a) len a 1 if a[j+1] in num:
            num[a[j+1]] += 1
     a[j+1] in num a[j+1] a j+1 j 1 num num[a[j+1]] += 1 num[a[j+1]] num a[j+1] a j+1 j 1 1 li.append(num.copy()) li.append li append num.copy() num.copy num copy p = list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for i in range(2**N):
    tmpli = copy.deepcopy(li)
    for j in range(N):
        if ((i >> j) & 1):
            for k in tmpli:
                if j + 1 in k:
                    k[j+1] = 0
    tmp = 0
    for b in range(len(p)):
        if sum(tmpli[b].values()) % 2 == p[b]:
            tmp += 1
    if tmp == len(p):
        count += 1 i range(2**N) range 2**N 2 N tmpli = copy.deepcopy(li) tmpli copy.deepcopy(li) copy.deepcopy copy deepcopy li for j in range(N):
        if ((i >> j) & 1):
            for k in tmpli:
                if j + 1 in k:
                    k[j+1] = 0
     j range(N) range N if ((i >> j) & 1):
            for k in tmpli:
                if j + 1 in k:
                    k[j+1] = 0
     (i >> j) & 1 i >> j i j 1 for k in tmpli:
                if j + 1 in k:
                    k[j+1] = 0
     k tmpli if j + 1 in k:
                    k[j+1] = 0
     j + 1 in k j + 1 j 1 k k[j+1] = 0 k[j+1] k j+1 j 1 0 tmp = 0 tmp 0 for b in range(len(p)):
        if sum(tmpli[b].values()) % 2 == p[b]:
            tmp += 1
     b range(len(p)) range len(p) len p if sum(tmpli[b].values()) % 2 == p[b]:
            tmp += 1
     sum(tmpli[b].values()) % 2 == p[b] sum(tmpli[b].values()) % 2 sum(tmpli[b].values()) sum tmpli[b].values() [b].values [b] tmpli b values 2 p[b] p b tmp += 1 tmp 1 if tmp == len(p):
        count += 1 tmp == len(p) tmp len(p) len p count += 1 count 1 print(count) print count M = map(int,input().split()) map(int,input().split()) M tmpli = [] [] tmpli p = [] [] p li = [] [] li tmp = 0 0 tmp num = {} {} num tmp += 1 1 tmp a = list(map(int,input().split())) list(map(int,input().split())) a N,M = map(int,input().split()) map(int,input().split()) N tmpli = copy.deepcopy(li) copy.deepcopy(li) tmpli tmp ={} {} tmp count = 0 0 count count += 1 1 count p = list(map(int,input().split())) list(map(int,input().split())) p
import copy
N,M = map(int,input().split())
num = {}
tmp ={}
tmpli = []
li = []
p = []
count = 0
for i in range(M):
    for i in range(N):
        num[i+1] = 0
    a = list(map(int,input().split()))
    for j in range(len(a)-1):
        if a[j+1] in num:
            num[a[j+1]] += 1
    li.append(num.copy())
p = list(map(int,input().split()))

for i in range(2**N):
    tmpli = copy.deepcopy(li)
    for j in range(N):
        if ((i >> j) & 1):
            for k in tmpli:
                if j + 1 in k:
                    k[j+1] = 0
    tmp = 0
    for b in range(len(p)):
        if sum(tmpli[b].values()) % 2 == p[b]:
            tmp += 1
    if tmp == len(p):
        count += 1
print(count)