import copy

def dfs(i,lst):
    global ans
    if i==n:
        ans.append(lst)
        return
    tmp1 = copy.copy(lst)
    tmp1.append(0)
    dfs(i+1,tmp1)
    tmp2 = copy.copy(lst)
    tmp2.append(1)
    dfs(i+1,tmp2)

n,m = map(int,input().split())
ans = []
tmp = [0]
dfs(0,tmp)
#print(ans)
s = []
k = []
for i in range(m):
    tmp = list(map(int,input().split()))
    k.append(tmp[0])
    s.append(tmp[1:])
p = list(map(int,input().split()))
#print(k)
#print(s)
#print(p)
cnt = 0
for i in range(len(ans)):
    cnt_i = 0
    for mi in range(m):
        sum_s = 0
        for ki in range(len(s[mi])):
            sum_s += ans[i][s[mi][ki]]
        if sum_s%2==p[mi]:
            cnt_i += 1
    if cnt_i==m:
        cnt += 1
print(cnt) import copy copy def dfs(i,lst):
    global ans
    if i==n:
        ans.append(lst)
        return
    tmp1 = copy.copy(lst)
    tmp1.append(0)
    dfs(i+1,tmp1)
    tmp2 = copy.copy(lst)
    tmp2.append(1)
    dfs(i+1,tmp2) dfs global ans if i==n:
        ans.append(lst)
        return
     i==n i n ans.append(lst) ans.append ans append lst return tmp1 = copy.copy(lst) tmp1 copy.copy(lst) copy.copy copy copy lst tmp1.append(0) tmp1.append tmp1 append 0 dfs(i+1,tmp1) dfs i+1 i 1 tmp1 tmp2 = copy.copy(lst) tmp2 copy.copy(lst) copy.copy copy copy lst tmp2.append(1) tmp2.append tmp2 append 1 dfs(i+1,tmp2) dfs i+1 i 1 tmp2 i i lst lst n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ans = [] ans [] tmp = [0] tmp [0] 0 dfs(0,tmp) dfs 0 tmp s = [] s [] k = [] k [] for i in range(m):
    tmp = list(map(int,input().split()))
    k.append(tmp[0])
    s.append(tmp[1:]) i range(m) range m tmp = list(map(int,input().split())) tmp list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k.append(tmp[0]) k.append k append tmp[0] tmp 0 s.append(tmp[1:]) s.append s append tmp[1:] tmp 1: 1 p = list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split cnt = 0 cnt 0 for i in range(len(ans)):
    cnt_i = 0
    for mi in range(m):
        sum_s = 0
        for ki in range(len(s[mi])):
            sum_s += ans[i][s[mi][ki]]
        if sum_s%2==p[mi]:
            cnt_i += 1
    if cnt_i==m:
        cnt += 1 i range(len(ans)) range len(ans) len ans cnt_i = 0 cnt_i 0 for mi in range(m):
        sum_s = 0
        for ki in range(len(s[mi])):
            sum_s += ans[i][s[mi][ki]]
        if sum_s%2==p[mi]:
            cnt_i += 1
     mi range(m) range m sum_s = 0 sum_s 0 for ki in range(len(s[mi])):
            sum_s += ans[i][s[mi][ki]]
         ki range(len(s[mi])) range len(s[mi]) len s[mi] s mi sum_s += ans[i][s[mi][ki]] sum_s ans[i][s[mi][ki]] [i] ans i s[mi][ki] [mi] s mi ki if sum_s%2==p[mi]:
            cnt_i += 1
     sum_s%2==p[mi] sum_s%2 sum_s 2 p[mi] p mi cnt_i += 1 cnt_i 1 if cnt_i==m:
        cnt += 1 cnt_i==m cnt_i m cnt += 1 cnt 1 print(cnt) print cnt cnt += 1 1 cnt tmp = [0] [0] tmp sum_s = 0 0 sum_s cnt_i = 0 0 cnt_i k = [] [] k cnt_i += 1 1 cnt_i s = [] [] s cnt = 0 0 cnt sum_s += ans[i][s[mi][ki]] ans[i][s[mi][ki]] sum_s n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m ans = [] [] ans p = list(map(int,input().split())) list(map(int,input().split())) p def dfs(i,lst):
    global ans
    if i==n:
        ans.append(lst)
        return
    tmp1 = copy.copy(lst)
    tmp1.append(0)
    dfs(i+1,tmp1)
    tmp2 = copy.copy(lst)
    tmp2.append(1)
    dfs(i+1,tmp2) def dfs(i,lst):
    global ans
    if i==n:
        ans.append(lst)
        return
    tmp1 = copy.copy(lst)
    tmp1.append(0)
    dfs(i+1,tmp1)
    tmp2 = copy.copy(lst)
    tmp2.append(1)
    dfs(i+1,tmp2) dfs tmp = list(map(int,input().split())) list(map(int,input().split())) tmp
import copy

def dfs(i,lst):
    global ans
    if i==n:
        ans.append(lst)
        return
    tmp1 = copy.copy(lst)
    tmp1.append(0)
    dfs(i+1,tmp1)
    tmp2 = copy.copy(lst)
    tmp2.append(1)
    dfs(i+1,tmp2)

n,m = map(int,input().split())
ans = []
tmp = [0]
dfs(0,tmp)
#print(ans)
s = []
k = []
for i in range(m):
    tmp = list(map(int,input().split()))
    k.append(tmp[0])
    s.append(tmp[1:])
p = list(map(int,input().split()))
#print(k)
#print(s)
#print(p)
cnt = 0
for i in range(len(ans)):
    cnt_i = 0
    for mi in range(m):
        sum_s = 0
        for ki in range(len(s[mi])):
            sum_s += ans[i][s[mi][ki]]
        if sum_s%2==p[mi]:
            cnt_i += 1
    if cnt_i==m:
        cnt += 1
print(cnt)