import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n,m = imap()
k,s = [],[]
for i in range(m):
    tmp = iarr()
    k.append(tmp[0])
    s.append([num-1 for num in tmp[1:]])
p = iarr()

ans = 0
for i in range(2**n):
    bin = iarr(n)
    for j in range(n):
        if i>>j&1: bin[j] = 1
    flag = 1
    for ii,ss in enumerate(s):
        cnt = 0
        for num in ss: cnt += bin[num]
        if cnt%2 == ii: continue
        else: flag = 0; break
    if flag: ans += 1
print(ans)

