from itertools import product, repeat
import numpy as np

input_row = lambda : [int(_) for _ in input().split(' ')]

N, M = input_row()
C = np.zeros((M, N), dtype=np.int32)

for i in range(M):
    s = np.array(input_row()[1:]) # ignore k
    C[i, s-1] = 1 # s_ to zero index.

p = input_row()

all_on_num = 0
for S_ in product(*(repeat([1, 0], N))):
    S = np.array(S_)

    L = C.dot(S)%2 == p

    if len(L[L == True]) == M:
        all_on_num += 1
print(all_on_num)
 from itertools import product, repeat import numpy as np numpy int(_) for _ in input().split(' ') for _ in input().split(' ') _ input().split(' ') ().split () input split ' ' for _ in input().split(' ') int(_) int _ input_row = lambda : [int(_) for _ in input().split(' ')] input_row lambda : [int(_) for _ in input().split(' ')] [int(_) for _ in input().split(' ')] N, M = input_row() N input_row() input_row M C = np.zeros((M, N), dtype=np.int32) C np.zeros((M, N), dtype=np.int32) np.zeros np zeros (M, N) M N dtype=np.int32 dtype np.int32 np int32 for i in range(M):
    s = np.array(input_row()[1:]) # ignore k
    C[i, s-1] = 1 # s_ to zero index. i range(M) range M s = np.array(input_row()[1:]) s np.array(input_row()[1:]) np.array np array input_row()[1:] () input_row 1: 1 C[i, s-1] = 1 C[i, s-1] C i 1 p = input_row() p input_row() input_row all_on_num = 0 all_on_num 0 for S_ in product(*(repeat([1, 0], N))):
    S = np.array(S_)

    L = C.dot(S)%2 == p

    if len(L[L == True]) == M:
        all_on_num += 1 S_ product(*(repeat([1, 0], N))) product *(repeat([1, 0], N)) repeat([1, 0], N) repeat [1, 0] 1 0 N S = np.array(S_) S np.array(S_) np.array np array S_ L = C.dot(S)%2 == p L C.dot(S)%2 == p C.dot(S)%2 C.dot(S) C.dot C dot S 2 p if len(L[L == True]) == M:
        all_on_num += 1 len(L[L == True]) == M len(L[L == True]) len L[L == True] L L == True L True M all_on_num += 1 all_on_num 1 print(all_on_num) print all_on_num M = input_row() input_row() M p = input_row() input_row() p all_on_num = 0 0 all_on_num N, M = input_row() input_row() N all_on_num += 1 1 all_on_num C = np.zeros((M, N), dtype=np.int32) np.zeros((M, N), dtype=np.int32) C S = np.array(S_) np.array(S_) S s = np.array(input_row()[1:]) np.array(input_row()[1:]) s L = C.dot(S)%2 == p C.dot(S)%2 == p L input_row = lambda : [int(_) for _ in input().split(' ')] lambda : [int(_) for _ in input().split(' ')] input_row
from itertools import product, repeat
import numpy as np

input_row = lambda : [int(_) for _ in input().split(' ')]

N, M = input_row()
C = np.zeros((M, N), dtype=np.int32)

for i in range(M):
    s = np.array(input_row()[1:]) # ignore k
    C[i, s-1] = 1 # s_ to zero index.

p = input_row()

all_on_num = 0
for S_ in product(*(repeat([1, 0], N))):
    S = np.array(S_)

    L = C.dot(S)%2 == p

    if len(L[L == True]) == M:
        all_on_num += 1
print(all_on_num)

