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
from fractions import gcd
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 inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
s = [[0] * n for i in range(m)]
for i in range(m):
    tmp = inpl()
    for j in range(len(tmp) - 1):
        s[i][tmp[j+1]-1] = 1
p = inpl()

ans = 0
for i in range(2**n):
    for j in range(m):
        cnt = 0
        for k in range(n):
            if s[j][k] == 1 and (i >> k) & 1 == 1:
                cnt += 1
        if p[j] != (cnt % 2):
            break
    else:
        ans += 1
        continue
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 from fractions import gcd input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 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 [0] * n for i in range(m) for i in range(m) i range(m) range m for i in range(m) [0] * n [0] 0 n s = [[0] * n for i in range(m)] s [[0] * n for i in range(m)] for i in range(m):
    tmp = inpl()
    for j in range(len(tmp) - 1):
        s[i][tmp[j+1]-1] = 1 i range(m) range m tmp = inpl() tmp inpl() inpl for j in range(len(tmp) - 1):
        s[i][tmp[j+1]-1] = 1 j range(len(tmp) - 1) range len(tmp) - 1 len(tmp) len tmp 1 s[i][tmp[j+1]-1] = 1 s[i][tmp[j+1]-1] [i] s i tmp[j+1]-1 tmp[j+1] tmp j+1 j 1 1 1 p = inpl() p inpl() inpl ans = 0 ans 0 for i in range(2**n):
    for j in range(m):
        cnt = 0
        for k in range(n):
            if s[j][k] == 1 and (i >> k) & 1 == 1:
                cnt += 1
        if p[j] != (cnt % 2):
            break
    else:
        ans += 1
        continue i range(2**n) range 2**n 2 n for j in range(m):
        cnt = 0
        for k in range(n):
            if s[j][k] == 1 and (i >> k) & 1 == 1:
                cnt += 1
        if p[j] != (cnt % 2):
            break
    else:
        ans += 1
        continue j range(m) range m cnt = 0 cnt 0 for k in range(n):
            if s[j][k] == 1 and (i >> k) & 1 == 1:
                cnt += 1
         k range(n) range n if s[j][k] == 1 and (i >> k) & 1 == 1:
                cnt += 1
         s[j][k] == 1 and (i >> k) & 1 == 1 s[j][k] == 1 s[j][k] [j] s j k 1 (i >> k) & 1 == 1 (i >> k) & 1 i >> k i k 1 1 cnt += 1 cnt 1 if p[j] != (cnt % 2):
            break
     p[j] != (cnt % 2) p[j] p j cnt % 2 cnt 2 break ans += 1 ans 1 continue print(ans) print ans mod = 10**9+7 10**9+7 mod def inpls(): return list(input().split()) def inpls(): return list(input().split()) inpls m = inpm() inpm() m def inplm(n): return list(int(input()) for _ in range(n)) def inplm(n): return list(int(input()) for _ in range(n)) inplm def inplL(n): return [list(input()) for _ in range(n)] def inplL(n): return [list(input()) for _ in range(n)] inplL def inp(): return int(input()) def inp(): return int(input()) inp s = [[0] * n for i in range(m)] [[0] * n for i in range(m)] s def inpm(): return map(int,input().split()) def inpm(): return map(int,input().split()) inpm n,m = inpm() inpm() n ans += 1 1 ans 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 ans = 0 0 ans 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 cnt += 1 1 cnt tmp = inpl() inpl() tmp p = inpl() inpl() p cnt = 0 0 cnt def inpl(): return list(map(int, input().split())) def inpl(): return list(map(int, input().split())) inpl input = sys.stdin.readline sys.stdin.readline input def inplT(n): return [tuple(input()) for _ in range(n)] def inplT(n): return [tuple(input()) for _ in range(n)] inplT
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
from fractions import gcd
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 inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
s = [[0] * n for i in range(m)]
for i in range(m):
    tmp = inpl()
    for j in range(len(tmp) - 1):
        s[i][tmp[j+1]-1] = 1
p = inpl()

ans = 0
for i in range(2**n):
    for j in range(m):
        cnt = 0
        for k in range(n):
            if s[j][k] == 1 and (i >> k) & 1 == 1:
                cnt += 1
        if p[j] != (cnt % 2):
            break
    else:
        ans += 1
        continue
print(ans)