n, m = map(int, input().split())
bulbs = []
for _ in range(m):
    b = tuple(map(int, input().split()))
    bulbs.append(b[1:])

p = list(map(int, input().split()))

ans = 0

for switch in range(2**n):
    check = [0] * m
    for i, bulb in enumerate(bulbs):
        cnt = 0
        for b in bulb:
            if switch >> (b-1) & 1:
                cnt += 1
            
        if cnt % 2 == p[i]:
            check[i] = True
        else:
            check[i] = False
    
    if  all(check):
        ans += 1

print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m bulbs = [] bulbs [] for _ in range(m):
    b = tuple(map(int, input().split()))
    bulbs.append(b[1:]) _ range(m) range m b = tuple(map(int, input().split())) b tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split bulbs.append(b[1:]) bulbs.append bulbs append b[1:] b 1: 1 p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for switch in range(2**n):
    check = [0] * m
    for i, bulb in enumerate(bulbs):
        cnt = 0
        for b in bulb:
            if switch >> (b-1) & 1:
                cnt += 1
            
        if cnt % 2 == p[i]:
            check[i] = True
        else:
            check[i] = False
    
    if  all(check):
        ans += 1 switch range(2**n) range 2**n 2 n check = [0] * m check [0] * m [0] 0 m for i, bulb in enumerate(bulbs):
        cnt = 0
        for b in bulb:
            if switch >> (b-1) & 1:
                cnt += 1
            
        if cnt % 2 == p[i]:
            check[i] = True
        else:
            check[i] = False
    
     i bulb enumerate(bulbs) enumerate bulbs cnt = 0 cnt 0 for b in bulb:
            if switch >> (b-1) & 1:
                cnt += 1
            
         b bulb if switch >> (b-1) & 1:
                cnt += 1
            
         switch >> (b-1) & 1 switch >> (b-1) switch b-1 b 1 1 cnt += 1 cnt 1 if cnt % 2 == p[i]:
            check[i] = True
        else:
            check[i] = False
    
     cnt % 2 == p[i] cnt % 2 cnt 2 p[i] p i check[i] = True check[i] check i True check[i] = False check[i] check i False if  all(check):
        ans += 1 all(check) all check ans += 1 ans 1 print(ans) print ans check = [0] * m [0] * m check m = map(int, input().split()) map(int, input().split()) m cnt = 0 0 cnt ans = 0 0 ans cnt += 1 1 cnt bulbs = [] [] bulbs p = list(map(int, input().split())) list(map(int, input().split())) p ans += 1 1 ans n, m = map(int, input().split()) map(int, input().split()) n b = tuple(map(int, input().split())) tuple(map(int, input().split())) b
n, m = map(int, input().split())
bulbs = []
for _ in range(m):
    b = tuple(map(int, input().split()))
    bulbs.append(b[1:])

p = list(map(int, input().split()))

ans = 0

for switch in range(2**n):
    check = [0] * m
    for i, bulb in enumerate(bulbs):
        cnt = 0
        for b in bulb:
            if switch >> (b-1) & 1:
                cnt += 1
            
        if cnt % 2 == p[i]:
            check[i] = True
        else:
            check[i] = False
    
    if  all(check):
        ans += 1

print(ans)