N,M = map(int,input().split())

k=[]
s=[]

for i in range(M):
    switch = list(map(int,input().split()))
    k.append(switch[0])
    s.append(switch[1:])
    
p = list(map(int,input().split()))


count = 0
for i in range(2**N):
    lighton_num = 0
    for m in range(M):
        switchon_num = 0
        for j in range(k[m]):
            
            if (i>>(s[m][j]-1)) &1== 1:
                switchon_num+=1
            
        
        if switchon_num%2 == p[m]:
            lighton_num += 1
        # print(bin(i), m, j,switchon_num,p[m], lighton_num, count)
        
    if lighton_num == M:
        count += 1

print(count) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M k=[] k [] s=[] s [] for i in range(M):
    switch = list(map(int,input().split()))
    k.append(switch[0])
    s.append(switch[1:])
     i range(M) range M switch = list(map(int,input().split())) switch list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k.append(switch[0]) k.append k append switch[0] switch 0 s.append(switch[1:]) s.append s append switch[1:] switch 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 count = 0 count 0 for i in range(2**N):
    lighton_num = 0
    for m in range(M):
        switchon_num = 0
        for j in range(k[m]):
            
            if (i>>(s[m][j]-1)) &1== 1:
                switchon_num+=1
            
        
        if switchon_num%2 == p[m]:
            lighton_num += 1
        # print(bin(i), m, j,switchon_num,p[m], lighton_num, count)
        
    if lighton_num == M:
        count += 1 i range(2**N) range 2**N 2 N lighton_num = 0 lighton_num 0 for m in range(M):
        switchon_num = 0
        for j in range(k[m]):
            
            if (i>>(s[m][j]-1)) &1== 1:
                switchon_num+=1
            
        
        if switchon_num%2 == p[m]:
            lighton_num += 1
        # print(bin(i), m, j,switchon_num,p[m], lighton_num, count)
        
     m range(M) range M switchon_num = 0 switchon_num 0 for j in range(k[m]):
            
            if (i>>(s[m][j]-1)) &1== 1:
                switchon_num+=1
            
        
         j range(k[m]) range k[m] k m if (i>>(s[m][j]-1)) &1== 1:
                switchon_num+=1
            
        
         (i>>(s[m][j]-1)) &1== 1 (i>>(s[m][j]-1)) &1 i>>(s[m][j]-1) i s[m][j]-1 s[m][j] [m] s m j 1 1 1 switchon_num+=1 switchon_num 1 if switchon_num%2 == p[m]:
            lighton_num += 1
        # print(bin(i), m, j,switchon_num,p[m], lighton_num, count)
        
     switchon_num%2 == p[m] switchon_num%2 switchon_num 2 p[m] p m lighton_num += 1 lighton_num 1 if lighton_num == M:
        count += 1 lighton_num == M lighton_num M count += 1 count 1 print(count) print count N,M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M switch = list(map(int,input().split())) list(map(int,input().split())) switch lighton_num = 0 0 lighton_num k=[] [] k s=[] [] s p = list(map(int,input().split())) list(map(int,input().split())) p switchon_num = 0 0 switchon_num switchon_num+=1 1 switchon_num count = 0 0 count lighton_num += 1 1 lighton_num count += 1 1 count
N,M = map(int,input().split())

k=[]
s=[]

for i in range(M):
    switch = list(map(int,input().split()))
    k.append(switch[0])
    s.append(switch[1:])
    
p = list(map(int,input().split()))


count = 0
for i in range(2**N):
    lighton_num = 0
    for m in range(M):
        switchon_num = 0
        for j in range(k[m]):
            
            if (i>>(s[m][j]-1)) &1== 1:
                switchon_num+=1
            
        
        if switchon_num%2 == p[m]:
            lighton_num += 1
        # print(bin(i), m, j,switchon_num,p[m], lighton_num, count)
        
    if lighton_num == M:
        count += 1

print(count)