import itertools

def allCombination(n):
    switch = [i for i in range(1,n+1)] 
    slis = []
    for i in range(0,n+1):
        for pair in itertools.combinations(switch, i):
            slis.append(pair)
    return slis

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

slis = allCombination(n)

cnt = 0
for s in slis:
    flag = 1
    for i,eachs in enumerate(kS):
        same = set(eachs[1:]) & set(s)
        if len(same) % 2 != p[i]:
            flag = 0
    
    if flag:
        cnt += 1

print(cnt) import itertools itertools def allCombination(n):
    switch = [i for i in range(1,n+1)] 
    slis = []
    for i in range(0,n+1):
        for pair in itertools.combinations(switch, i):
            slis.append(pair)
    return slis allCombination 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)] slis = [] slis [] for i in range(0,n+1):
        for pair in itertools.combinations(switch, i):
            slis.append(pair)
     i range(0,n+1) range 0 n+1 n 1 for pair in itertools.combinations(switch, i):
            slis.append(pair)
     pair itertools.combinations(switch, i) itertools.combinations itertools combinations switch i slis.append(pair) slis.append slis append pair return slis slis n n 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 slis = allCombination(n) slis allCombination(n) allCombination n cnt = 0 cnt 0 for s in slis:
    flag = 1
    for i,eachs in enumerate(kS):
        same = set(eachs[1:]) & set(s)
        if len(same) % 2 != p[i]:
            flag = 0
    
    if flag:
        cnt += 1 s slis flag = 1 flag 1 for i,eachs in enumerate(kS):
        same = set(eachs[1:]) & set(s)
        if len(same) % 2 != p[i]:
            flag = 0
    
     i eachs enumerate(kS) enumerate kS same = set(eachs[1:]) & set(s) same set(eachs[1:]) & set(s) set(eachs[1:]) set eachs[1:] eachs 1: 1 set(s) set s if len(same) % 2 != p[i]:
            flag = 0
    
     len(same) % 2 != p[i] len(same) % 2 len(same) len same 2 p[i] p i flag = 0 flag 0 if flag:
        cnt += 1 flag cnt += 1 cnt 1 print(cnt) print cnt def allCombination(n):
    switch = [i for i in range(1,n+1)] 
    slis = []
    for i in range(0,n+1):
        for pair in itertools.combinations(switch, i):
            slis.append(pair)
    return slis def allCombination(n):
    switch = [i for i in range(1,n+1)] 
    slis = []
    for i in range(0,n+1):
        for pair in itertools.combinations(switch, i):
            slis.append(pair)
    return slis allCombination flag = 0 0 flag n,m = map(int,input().split()) map(int,input().split()) n kS = [list(map(int,input().split())) for i in range(m)] [list(map(int,input().split())) for i in range(m)] kS cnt += 1 1 cnt m = map(int,input().split()) map(int,input().split()) m p = list(map(int,input().split())) list(map(int,input().split())) p slis = allCombination(n) allCombination(n) slis same = set(eachs[1:]) & set(s) set(eachs[1:]) & set(s) same cnt = 0 0 cnt flag = 1 1 flag
import itertools

def allCombination(n):
    switch = [i for i in range(1,n+1)] 
    slis = []
    for i in range(0,n+1):
        for pair in itertools.combinations(switch, i):
            slis.append(pair)
    return slis

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

slis = allCombination(n)

cnt = 0
for s in slis:
    flag = 1
    for i,eachs in enumerate(kS):
        same = set(eachs[1:]) & set(s)
        if len(same) % 2 != p[i]:
            flag = 0
    
    if flag:
        cnt += 1

print(cnt)