#N個のスイッチ（1,2,3,...,10）M個の電球（1,2,3,...,10）
N, M = map(int, input().split())
Light_list = []
for _ in range(M):
    Light_list.append(list(map(lambda x:x-1, list(map(int, input().split())))))
Light_requirement_list = list(map(int, input().split()))

for  idx, Light_list_element in enumerate(Light_list):
    Light_list_element.append(Light_requirement_list[idx])
    Light_list_element.pop(0)
#ここまででLight_list[i]の末尾に1か2かの条件が入る
#例　[[0, 1, 0], [1, 1]]

import itertools
#switch_state_list[i][j]はiパターン目のj番目のスイッチの状態を'On''Off'で返す
#例　[('On', 'On'), ('On', 'Off'), ('Off', 'On'), ('Off', 'Off')]
switch_state_list = list(itertools.product(('On', 'Off'), repeat=N))

Ans_list = []
for Light_list_element in Light_list:
    p = Light_list_element.pop()
    for switch_state_list_element in switch_state_list:
        cnt = 0
        for Light_idx in Light_list_element:
            if switch_state_list_element[Light_idx] == 'On':
                cnt += 1
        if cnt % 2 == p:
            Ans_list.append(switch_state_list_element)
            
import collections
c = collections.Counter(Ans_list).most_common()

cnt = 0
for i in c:
    if i[1] == 2:
        cnt += 1
print(cnt)