import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

N,M = mint()
S = [lint() for _ in range(M)]
P = lint()
ans = 0
for k in range(1<<N):
    tmp = [(k>>i)&1 for i in range(N)]
    now = True
    for s,p in zip(S,P):
        on = 0
        for i in s[1:]:
            on += tmp[i-1]
        if on%2!=p:
            now = False
            break
    ans = ans+1 if now else ans
print(ans) import sys sys from sys import exit from collections import deque from bisect import bisect_left, bisect_right, insort_left, insort_right from heapq import heapify, heappop, heappush from itertools import product, permutations, combinations, combinations_with_replacement from functools import reduce from math import sin, cos, tan, asin, acos, atan, degrees, radians sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 INF = 10**20 INF 10**20 10 20 eps = 1.0e-20 eps 1.0e-20 MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 def lcm(x,y):
    return x*y//gcd(x,y) lcm return x*y//gcd(x,y) x*y//gcd(x,y) x*y x y gcd(x,y) gcd x y x x y y def lgcd(l):
    return reduce(gcd,l) lgcd return reduce(gcd,l) reduce(gcd,l) reduce gcd l l l def llcm(l):
    return reduce(lcm,l) llcm return reduce(lcm,l) reduce(lcm,l) reduce lcm l l l def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod) powmod return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod) pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod) i<0 i 0 pow(n,mod-1+i,mod) pow n mod-1+i mod-1 mod 1 i mod pow(n,i,mod) pow n i mod n n i i mod mod def div2(x):
    return x.bit_length() div2 return x.bit_length() x.bit_length() x.bit_length x bit_length x x def div10(x):
    return len(str(x))-(x==0) div10 return len(str(x))-(x==0) len(str(x))-(x==0) len(str(x)) len str(x) str x x==0 x 0 x x def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans perm ans = 1 ans 1 for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
     i range(1,n+1) range 1 n+1 n 1 ans *= i ans i if mod!=None:
            ans %= mod
     mod!=None mod None ans %= mod ans mod return ans ans n n mod=None mod None def intput():
    return int(input()) intput return int(input()) int(input()) int input() input def mint():
    return map(int,input().split()) mint return map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split def lint():
    return list(map(int,input().split())) lint return list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split def ilint():
    return int(input()), list(map(int,input().split())) ilint return int(input()), list(map(int,input().split())) return int(input()), list(map(int,input().split())) int(input()) int input() input list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1]) judge print(l[0] if x else l[1]) print l[0] if x else l[1] x l[0] l 0 l[1] l 1 x x l=['Yes', 'No'] l ['Yes', 'No'] 'Yes' 'No' def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep) lprint for x in l:
        print(x, end=sep) x l print(x, end=sep) print x end=sep end sep l l sep='\n' sep '\n' def ston(c, c0='a'):
    return ord(c)-ord(c0) ston return ord(c)-ord(c0) ord(c)-ord(c0) ord(c) ord c ord(c0) ord c0 c c c0='a' c0 'a' def ntos(x, c0='a'):
    return chr(x+ord(c0)) ntos return chr(x+ord(c0)) chr(x+ord(c0)) chr x+ord(c0) x ord(c0) ord c0 x x c0='a' c0 'a' class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1 counter def __init__(self, *args):
        super().__init__(args)
     __init__ super().__init__(args) ().__init__ () super __init__ args self self *args def add(self,x):
        self.setdefault(x,0)
        self[x] += 1 add self.setdefault(x,0) self.setdefault self setdefault x 0 self[x] += 1 self[x] self x 1 self self x x dict class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k] comb def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
     __init__ self.l = [1] self.l self l [1] 1 self.n = n self.n self n n self.mod = mod self.mod self mod mod self self n n mod=None mod None def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k] get l,n,mod = self.l, self.n, self.mod l self.l self l n self.n self n mod self.mod self mod k = n-k if k>n//2 else k k n-k if k>n//2 else k k>n//2 k n//2 n 2 n-k n k k while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
         len(l)<=k len(l) len l k i = len(l) i len(l) len l l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod) l.append l append l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod mod==None mod None l[i-1]*(n+1-i)//i l[i-1]*(n+1-i) l[i-1] l i-1 i 1 n+1-i n+1 n 1 i i (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod l[i-1]*(n+1-i)*powmod(i,-1,mod) l[i-1]*(n+1-i) l[i-1] l i-1 i 1 n+1-i n+1 n 1 i powmod(i,-1,mod) powmod i -1 mod mod return l[k] l[k] l k self self k k N,M = mint() N mint() mint M lint() for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) lint() lint S = [lint() for _ in range(M)] S [lint() for _ in range(M)] P = lint() P lint() lint ans = 0 ans 0 for k in range(1<<N):
    tmp = [(k>>i)&1 for i in range(N)]
    now = True
    for s,p in zip(S,P):
        on = 0
        for i in s[1:]:
            on += tmp[i-1]
        if on%2!=p:
            now = False
            break
    ans = ans+1 if now else ans k range(1<<N) range 1<<N 1 N (k>>i)&1 for i in range(N) for i in range(N) i range(N) range N for i in range(N) (k>>i)&1 k>>i k i 1 tmp = [(k>>i)&1 for i in range(N)] tmp [(k>>i)&1 for i in range(N)] now = True now True for s,p in zip(S,P):
        on = 0
        for i in s[1:]:
            on += tmp[i-1]
        if on%2!=p:
            now = False
            break
     s p zip(S,P) zip S P on = 0 on 0 for i in s[1:]:
            on += tmp[i-1]
         i s[1:] s 1: 1 on += tmp[i-1] on tmp[i-1] tmp i-1 i 1 if on%2!=p:
            now = False
            break
     on%2!=p on%2 on 2 p now = False now False break ans = ans+1 if now else ans ans ans+1 if now else ans now ans+1 ans 1 ans print(ans) print ans def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1]) def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1]) judge ans = 0 0 ans eps = 1.0e-20 1.0e-20 eps def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans perm def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep) def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep) lprint def div2(x):
    return x.bit_length() def div2(x):
    return x.bit_length() div2 on += tmp[i-1] tmp[i-1] on def ilint():
    return int(input()), list(map(int,input().split())) def ilint():
    return int(input()), list(map(int,input().split())) ilint ans = ans+1 if now else ans ans+1 if now else ans ans def ntos(x, c0='a'):
    return chr(x+ord(c0)) def ntos(x, c0='a'):
    return chr(x+ord(c0)) ntos class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k] class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k] comb def intput():
    return int(input()) def intput():
    return int(input()) intput def llcm(l):
    return reduce(lcm,l) def llcm(l):
    return reduce(lcm,l) llcm tmp = [(k>>i)&1 for i in range(N)] [(k>>i)&1 for i in range(N)] tmp N,M = mint() mint() N def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod) def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod) powmod now = True True now class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1 class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1 counter P = lint() lint() P def lint():
    return list(map(int,input().split())) def lint():
    return list(map(int,input().split())) lint M = mint() mint() M on = 0 0 on def div10(x):
    return len(str(x))-(x==0) def div10(x):
    return len(str(x))-(x==0) div10 def mint():
    return map(int,input().split()) def mint():
    return map(int,input().split()) mint MOD = 10**9+7 10**9+7 MOD def lgcd(l):
    return reduce(gcd,l) def lgcd(l):
    return reduce(gcd,l) lgcd now = False False now INF = 10**20 10**20 INF def lcm(x,y):
    return x*y//gcd(x,y) def lcm(x,y):
    return x*y//gcd(x,y) lcm def ston(c, c0='a'):
    return ord(c)-ord(c0) def ston(c, c0='a'):
    return ord(c)-ord(c0) ston S = [lint() for _ in range(M)] [lint() for _ in range(M)] S
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

N,M = mint()
S = [lint() for _ in range(M)]
P = lint()
ans = 0
for k in range(1<<N):
    tmp = [(k>>i)&1 for i in range(N)]
    now = True
    for s,p in zip(S,P):
        on = 0
        for i in s[1:]:
            on += tmp[i-1]
        if on%2!=p:
            now = False
            break
    ans = ans+1 if now else ans
print(ans)