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



denkyu = []
for _ in range(M):
    s_list = list(map(int, input().split()))[1:]
    denkyu.append(s_list)
p_ist = list(map(int, input().split()))

ans = 0

for i in range(1, 2**N, 1):
    binary = format(i, '0{}b'.format(N))
    
    all_shine = True
    for s_list, p in zip(denkyu, p_ist):
        sum_ = 0
        for s in s_list:
            sum_ += int(binary[s-1])
        if sum_ % 2 == p:
            pass
        else:
            all_shine = False
            continue
            
    if all_shine:
        ans += 1
    

print(ans)      