import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
K = [IL() for i in range(M)]
p = IL()

data = []
for i in range(2**M):
    d = []
    for j in range(M):
        if ((i >> j) & 1) == 1:
            d.append(K[j])
    else:
        data.append(d)

ans = 0
for s in data:
    cnt = [0]*M
    for i in s:
        for j in i[1:]:
            cnt[j-1] += 1
    else:
        for k in range(M):
            if cnt[k]%2 == p[k]:
                continue
            else:
                break
        else:
            ans += 1

print(ans)