import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
def end_of_loop():raise StopIteration
    
    
def main():
    N, M = MI()
    Switch = [LI() for i in range(M)]
    P = LI()
    result = 0
    for i in range(2**N):
        result += 1
        for index, swich in enumerate(Switch):
            if swich[0] == 0:
                continue
            temp = 0
            for j in range(swich[0]):
                if i >> (swich[j+1]-1) & 1 == 1:
                    temp += 1
            if temp % 2 != P[index]:
                result-=1
                break
            
    print(result)
                    
                    
            
            
        
if __name__ == "__main__":
    main() import sys sys import math math from collections import defaultdict, deque from copy import deepcopy input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def RD(): return input().rstrip() RD def F(): return float(input().rstrip()) F def I(): return int(input().rstrip()) I def MI(): return map(int, input().split()) MI def MF(): return map(float,input().split()) MF def LI(): return tuple(map(int, input().split())) LI def LF(): return list(map(float,input().split())) LF [num for i in range(W)] for j in range(H) for j in range(H) j range(H) range H for j in range(H) [num for i in range(W)] def Init(H, W, num): return [[num for i in range(W)] for j in range(H)] Init H H W W num num def end_of_loop():raise StopIteration
    
     end_of_loop def main():
    N, M = MI()
    Switch = [LI() for i in range(M)]
    P = LI()
    result = 0
    for i in range(2**N):
        result += 1
        for index, swich in enumerate(Switch):
            if swich[0] == 0:
                continue
            temp = 0
            for j in range(swich[0]):
                if i >> (swich[j+1]-1) & 1 == 1:
                    temp += 1
            if temp % 2 != P[index]:
                result-=1
                break
            
    print(result)
                    
                    
            
            
         main N, M = MI() N MI() MI M LI() for i in range(M) for i in range(M) i range(M) range M for i in range(M) LI() LI Switch = [LI() for i in range(M)] Switch [LI() for i in range(M)] P = LI() P LI() LI result = 0 result 0 for i in range(2**N):
        result += 1
        for index, swich in enumerate(Switch):
            if swich[0] == 0:
                continue
            temp = 0
            for j in range(swich[0]):
                if i >> (swich[j+1]-1) & 1 == 1:
                    temp += 1
            if temp % 2 != P[index]:
                result-=1
                break
            
     i range(2**N) range 2**N 2 N result += 1 result 1 for index, swich in enumerate(Switch):
            if swich[0] == 0:
                continue
            temp = 0
            for j in range(swich[0]):
                if i >> (swich[j+1]-1) & 1 == 1:
                    temp += 1
            if temp % 2 != P[index]:
                result-=1
                break
            
     index swich enumerate(Switch) enumerate Switch if swich[0] == 0:
                continue
             swich[0] == 0 swich[0] swich 0 0 continue temp = 0 temp 0 for j in range(swich[0]):
                if i >> (swich[j+1]-1) & 1 == 1:
                    temp += 1
             j range(swich[0]) range swich[0] swich 0 if i >> (swich[j+1]-1) & 1 == 1:
                    temp += 1
             i >> (swich[j+1]-1) & 1 == 1 i >> (swich[j+1]-1) & 1 i >> (swich[j+1]-1) i swich[j+1]-1 swich[j+1] swich j+1 j 1 1 1 1 temp += 1 temp 1 if temp % 2 != P[index]:
                result-=1
                break
            
     temp % 2 != P[index] temp % 2 temp 2 P[index] P index result-=1 result 1 break print(result) print result if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def end_of_loop():raise StopIteration
    
     def end_of_loop():raise StopIteration
    
     end_of_loop def LF(): return list(map(float,input().split())) def LF(): return list(map(float,input().split())) LF def Init(H, W, num): return [[num for i in range(W)] for j in range(H)] def Init(H, W, num): return [[num for i in range(W)] for j in range(H)] Init def F(): return float(input().rstrip()) def F(): return float(input().rstrip()) F def main():
    N, M = MI()
    Switch = [LI() for i in range(M)]
    P = LI()
    result = 0
    for i in range(2**N):
        result += 1
        for index, swich in enumerate(Switch):
            if swich[0] == 0:
                continue
            temp = 0
            for j in range(swich[0]):
                if i >> (swich[j+1]-1) & 1 == 1:
                    temp += 1
            if temp % 2 != P[index]:
                result-=1
                break
            
    print(result)
                    
                    
            
            
         def main():
    N, M = MI()
    Switch = [LI() for i in range(M)]
    P = LI()
    result = 0
    for i in range(2**N):
        result += 1
        for index, swich in enumerate(Switch):
            if swich[0] == 0:
                continue
            temp = 0
            for j in range(swich[0]):
                if i >> (swich[j+1]-1) & 1 == 1:
                    temp += 1
            if temp % 2 != P[index]:
                result-=1
                break
            
    print(result)
                    
                    
            
            
         main def RD(): return input().rstrip() def RD(): return input().rstrip() RD def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI def I(): return int(input().rstrip()) def I(): return int(input().rstrip()) I def LI(): return tuple(map(int, input().split())) def LI(): return tuple(map(int, input().split())) LI input = sys.stdin.readline sys.stdin.readline input def MF(): return map(float,input().split()) def MF(): return map(float,input().split()) MF
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
def end_of_loop():raise StopIteration
    
    
def main():
    N, M = MI()
    Switch = [LI() for i in range(M)]
    P = LI()
    result = 0
    for i in range(2**N):
        result += 1
        for index, swich in enumerate(Switch):
            if swich[0] == 0:
                continue
            temp = 0
            for j in range(swich[0]):
                if i >> (swich[j+1]-1) & 1 == 1:
                    temp += 1
            if temp % 2 != P[index]:
                result-=1
                break
            
    print(result)
                    
                    
            
            
        
if __name__ == "__main__":
    main()