import sys
import numpy as np
import itertools

[N,M] = input().split()
N = int(N)
M = int(M)
a =[]
p = []
list_bin = []

for j in range(M):
    list_temp = [int(s) for s in input().split()]
    list_temp.pop(0)
    for i in range(N):
        if i+1 in list_temp:
            list_bin.append(1)
        else:
            list_bin.append(0)

    a.append(list_bin)
    list_bin = []
p = [int(s) for s in input().split()]

arr_switch = np.array(a)
arr_p = np.array(p)
arr_pattern = np.array(list(itertools.product([0,1], repeat=N)))

count = 0
flag = 1
for switch in arr_pattern:
    for m in range(M):
        if (not (np.dot(switch, arr_switch[m]) % 2 == arr_p[m])) or  (np.dot(switch, np.ones(N)) == -1):
           flag = 0
    if flag == 1:
        count = count + 1
    flag=1
print(count) import sys sys import numpy as np numpy import itertools itertools [N,M] = input().split() [N,M] N M input().split() ().split () input split N = int(N) N int(N) int N M = int(M) M int(M) int M a =[] a [] p = [] p [] list_bin = [] list_bin [] for j in range(M):
    list_temp = [int(s) for s in input().split()]
    list_temp.pop(0)
    for i in range(N):
        if i+1 in list_temp:
            list_bin.append(1)
        else:
            list_bin.append(0)

    a.append(list_bin)
    list_bin = [] j range(M) range M int(s) for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s) int s list_temp = [int(s) for s in input().split()] list_temp [int(s) for s in input().split()] list_temp.pop(0) list_temp.pop list_temp pop 0 for i in range(N):
        if i+1 in list_temp:
            list_bin.append(1)
        else:
            list_bin.append(0)

     i range(N) range N if i+1 in list_temp:
            list_bin.append(1)
        else:
            list_bin.append(0)

     i+1 in list_temp i+1 i 1 list_temp list_bin.append(1) list_bin.append list_bin append 1 list_bin.append(0) list_bin.append list_bin append 0 a.append(list_bin) a.append a append list_bin list_bin = [] list_bin [] int(s) for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s) int s p = [int(s) for s in input().split()] p [int(s) for s in input().split()] arr_switch = np.array(a) arr_switch np.array(a) np.array np array a arr_p = np.array(p) arr_p np.array(p) np.array np array p arr_pattern = np.array(list(itertools.product([0,1], repeat=N))) arr_pattern np.array(list(itertools.product([0,1], repeat=N))) np.array np array list(itertools.product([0,1], repeat=N)) list itertools.product([0,1], repeat=N) itertools.product itertools product [0,1] 0 1 repeat=N repeat N count = 0 count 0 flag = 1 flag 1 for switch in arr_pattern:
    for m in range(M):
        if (not (np.dot(switch, arr_switch[m]) % 2 == arr_p[m])) or  (np.dot(switch, np.ones(N)) == -1):
           flag = 0
    if flag == 1:
        count = count + 1
    flag=1 switch arr_pattern for m in range(M):
        if (not (np.dot(switch, arr_switch[m]) % 2 == arr_p[m])) or  (np.dot(switch, np.ones(N)) == -1):
           flag = 0
     m range(M) range M if (not (np.dot(switch, arr_switch[m]) % 2 == arr_p[m])) or  (np.dot(switch, np.ones(N)) == -1):
           flag = 0
     (not (np.dot(switch, arr_switch[m]) % 2 == arr_p[m])) or  (np.dot(switch, np.ones(N)) == -1) not (np.dot(switch, arr_switch[m]) % 2 == arr_p[m]) np.dot(switch, arr_switch[m]) % 2 == arr_p[m] np.dot(switch, arr_switch[m]) % 2 np.dot(switch, arr_switch[m]) np.dot np dot switch arr_switch[m] arr_switch m 2 arr_p[m] arr_p m np.dot(switch, np.ones(N)) == -1 np.dot(switch, np.ones(N)) np.dot np dot switch np.ones(N) np.ones np ones N -1 flag = 0 flag 0 if flag == 1:
        count = count + 1
     flag == 1 flag 1 count = count + 1 count count + 1 count 1 flag=1 flag 1 print(count) print count N = int(N) int(N) N list_bin = [] [] list_bin p = [] [] p M = int(M) int(M) M list_temp = [int(s) for s in input().split()] [int(s) for s in input().split()] list_temp flag=1 1 flag list_bin = [] [] list_bin count = 0 0 count flag = 0 0 flag arr_p = np.array(p) np.array(p) arr_p flag = 1 1 flag count = count + 1 count + 1 count p = [int(s) for s in input().split()] [int(s) for s in input().split()] p a =[] [] a arr_pattern = np.array(list(itertools.product([0,1], repeat=N))) np.array(list(itertools.product([0,1], repeat=N))) arr_pattern arr_switch = np.array(a) np.array(a) arr_switch
import sys
import numpy as np
import itertools

[N,M] = input().split()
N = int(N)
M = int(M)
a =[]
p = []
list_bin = []

for j in range(M):
    list_temp = [int(s) for s in input().split()]
    list_temp.pop(0)
    for i in range(N):
        if i+1 in list_temp:
            list_bin.append(1)
        else:
            list_bin.append(0)

    a.append(list_bin)
    list_bin = []
p = [int(s) for s in input().split()]

arr_switch = np.array(a)
arr_p = np.array(p)
arr_pattern = np.array(list(itertools.product([0,1], repeat=N)))

count = 0
flag = 1
for switch in arr_pattern:
    for m in range(M):
        if (not (np.dot(switch, arr_switch[m]) % 2 == arr_p[m])) or  (np.dot(switch, np.ones(N)) == -1):
           flag = 0
    if flag == 1:
        count = count + 1
    flag=1
print(count)
