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()[1:] for i in range(N)]
    P = LI()
    result = 0
    for i in range(2**N):
        temp = [0]*M
        for j in range(N):
            if i>>j & 1 != 0:
                for k in Switch[j]:
                    temp[k-1] += 1
        result += 1
        for num1, num2 in zip(temp, P):
            if num1 % 2 != num2:
                result -= 1
                break
    print(result)
            
        
if __name__ == "__main__":
    main()