import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#m = int(input())
n, m = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

l = []
for i in range(m):
    l.append(list(map(int, sys.stdin.readline().split())))

p = list(map(int, sys.stdin.readline().split()))

ans = 0
for i in range(2 ** n):
    g = format(i, "010b")
    for j in range(m):
        cnt = 0
        for k in range(1,l[j][0]+1):
            if g[9-l[j][k]] == "1":
                cnt += 1

        if cnt % 2 != p[j]:
            break

        if j == m - 1:
            ans += 1

print(ans)
    

    
    

        
