import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
S = inpll(m)
P = inpl()

ans = 0
for bi in itertools.product([0,1],repeat=n):
    for i in range(m):
        cnt = 0
        for j in range(S[i][0]):
            if bi[S[i][j+1]-1] == 1:
               cnt += 1
        if cnt%2 != P[i]:
            break
        else:
            continue
        break
    else:
        ans += 1

print(ans) import sys, bisect, math, itertools, string, queue, copy sys bisect math itertools string queue copy import numpy as np numpy import scipy scipy from collections import Counter,defaultdict,deque from itertools import permutations, combinations from heapq import heappop, heappush sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 def inp(): return int(input()) inp def inpm(): return map(int,input().split()) inpm def inpl(): return list(map(int, input().split())) inpl def inpls(): return list(input().split()) inpls def inplm(n): return list(int(input()) for _ in range(n)) inplm n n list(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(input()) list input() input def inplL(n): return [list(input()) for _ in range(n)] inplL n n tuple(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) tuple(input()) tuple input() input def inplT(n): return [tuple(input()) for _ in range(n)] inplT n n list(map(int, input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def inpll(n): return [list(map(int, input().split())) for _ in range(n)] inpll n n tuple(map(int, input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)] inplt n n list(map(int, input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) inplls n n n,m = inpm() n inpm() inpm m S = inpll(m) S inpll(m) inpll m P = inpl() P inpl() inpl ans = 0 ans 0 for bi in itertools.product([0,1],repeat=n):
    for i in range(m):
        cnt = 0
        for j in range(S[i][0]):
            if bi[S[i][j+1]-1] == 1:
               cnt += 1
        if cnt%2 != P[i]:
            break
        else:
            continue
        break
    else:
        ans += 1 bi itertools.product([0,1],repeat=n) itertools.product itertools product [0,1] 0 1 repeat=n repeat n for i in range(m):
        cnt = 0
        for j in range(S[i][0]):
            if bi[S[i][j+1]-1] == 1:
               cnt += 1
        if cnt%2 != P[i]:
            break
        else:
            continue
        break
    else:
        ans += 1 i range(m) range m cnt = 0 cnt 0 for j in range(S[i][0]):
            if bi[S[i][j+1]-1] == 1:
               cnt += 1
         j range(S[i][0]) range S[i][0] [i] S i 0 if bi[S[i][j+1]-1] == 1:
               cnt += 1
         bi[S[i][j+1]-1] == 1 bi[S[i][j+1]-1] bi S[i][j+1]-1 S[i][j+1] [i] S i j+1 j 1 1 1 cnt += 1 cnt 1 if cnt%2 != P[i]:
            break
        else:
            continue
         cnt%2 != P[i] cnt%2 cnt 2 P[i] P i break continue break ans += 1 ans 1 print(ans) print ans def inp(): return int(input()) def inp(): return int(input()) inp P = inpl() inpl() P def inpm(): return map(int,input().split()) def inpm(): return map(int,input().split()) inpm cnt += 1 1 cnt ans += 1 1 ans def inplm(n): return list(int(input()) for _ in range(n)) def inplm(n): return list(int(input()) for _ in range(n)) inplm def inpls(): return list(input().split()) def inpls(): return list(input().split()) inpls def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) inplls cnt = 0 0 cnt mod = 10**9+7 10**9+7 mod def inplT(n): return [tuple(input()) for _ in range(n)] def inplT(n): return [tuple(input()) for _ in range(n)] inplT def inplL(n): return [list(input()) for _ in range(n)] def inplL(n): return [list(input()) for _ in range(n)] inplL ans = 0 0 ans def inpl(): return list(map(int, input().split())) def inpl(): return list(map(int, input().split())) inpl def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)] def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)] inplt n,m = inpm() inpm() n m = inpm() inpm() m S = inpll(m) inpll(m) S def inpll(n): return [list(map(int, input().split())) for _ in range(n)] def inpll(n): return [list(map(int, input().split())) for _ in range(n)] inpll
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
S = inpll(m)
P = inpl()

ans = 0
for bi in itertools.product([0,1],repeat=n):
    for i in range(m):
        cnt = 0
        for j in range(S[i][0]):
            if bi[S[i][j+1]-1] == 1:
               cnt += 1
        if cnt%2 != P[i]:
            break
        else:
            continue
        break
    else:
        ans += 1

print(ans)