# まずはナイーブに書く
# スイッチは0から始まる

N, M = map(int, input().split())
light_s_dict = dict()
light_n_dict = dict()

# 繋がっているスイッチ
for i in range(1, M+1):
    l = [int(j) for j in input().split()]
    connected_s = [0]*N
    for s in l[1:]:
        connected_s[s-1] = 1
    light_s_dict[i] = connected_s
    light_n_dict[i] = l[0]

# スイッチの全パターン
s_patterns = []
for i in range(2**N):
    p_str = bin(i)[2:].zfill(N)
    s_patterns.append([int(i) for i in list(p_str)])
    
# 点灯条件
light_conditions = [int(p) for p in input().split()]

# 全探索
ans = 0
for pattern in s_patterns:
    cond = 0
    for light in range(1, M+1): # 全部のlightに対して
        for i, p in enumerate(pattern):
            if p == 1:
                cond += light_s_dict[light][i]
        if cond % 2 != light_conditions[light-1]:
            break
    else: # 全てのlightに対して正常に終了すれば
        ans += 1
print(ans)