n, m = map(int, input().split())
sw = []
ki = []
counter = 0
for i in range(m):
    inp = list(map(int, input().split()))
    sw.append(inp[1:])
    ki.append(inp[0])
criterion = list(map(int, input().split()))
for switch in range(2**n):
    flash = list(range(m))     #flash+criterion%2 = 0なら発光
    for j in range(n):
        if ((switch >> j) & 1):
            for light in range(m):  
                if (j + 1) in sw[light]:
                    flash[light] += 1
    token = True
    for light in range(m):
        if (flash[light] + criterion[light]) % 2 == 1:
            token = False
    if token:
        counter+= 1
print(counter)