import itertools
N,M = map(int,input().split())
Switch = []
for i in range(M):
    Swi = list(map(int,input().split()))
    S = Swi[0]
    Switch.append(Swi[1:S+1])
Plist = list(map(int,input().split()))
Ans = 0
L = [0,1]
c_list = list(itertools.product(L, repeat=N))
for comb in c_list:
    for i in range(M):
        Jud = 0
        Swi = Switch[i]
        for j in Swi:
            Jud += comb[j-1]
        if Jud%2 != Plist[i]:
            break
        elif i == M-1:
            Ans += 1
print(Ans) import itertools itertools N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M Switch = [] Switch [] for i in range(M):
    Swi = list(map(int,input().split()))
    S = Swi[0]
    Switch.append(Swi[1:S+1]) i range(M) range M Swi = list(map(int,input().split())) Swi list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split S = Swi[0] S Swi[0] Swi 0 Switch.append(Swi[1:S+1]) Switch.append Switch append Swi[1:S+1] Swi 1:S+1 1 S+1 S 1 Plist = list(map(int,input().split())) Plist list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split Ans = 0 Ans 0 L = [0,1] L [0,1] 0 1 c_list = list(itertools.product(L, repeat=N)) c_list list(itertools.product(L, repeat=N)) list itertools.product(L, repeat=N) itertools.product itertools product L repeat=N repeat N for comb in c_list:
    for i in range(M):
        Jud = 0
        Swi = Switch[i]
        for j in Swi:
            Jud += comb[j-1]
        if Jud%2 != Plist[i]:
            break
        elif i == M-1:
            Ans += 1 comb c_list for i in range(M):
        Jud = 0
        Swi = Switch[i]
        for j in Swi:
            Jud += comb[j-1]
        if Jud%2 != Plist[i]:
            break
        elif i == M-1:
            Ans += 1 i range(M) range M Jud = 0 Jud 0 Swi = Switch[i] Swi Switch[i] Switch i for j in Swi:
            Jud += comb[j-1]
         j Swi Jud += comb[j-1] Jud comb[j-1] comb j-1 j 1 if Jud%2 != Plist[i]:
            break
        elif i == M-1:
            Ans += 1 Jud%2 != Plist[i] Jud%2 Jud 2 Plist[i] Plist i break elif i == M-1:
            Ans += 1 i == M-1 i M-1 M 1 Ans += 1 Ans 1 print(Ans) print Ans N,M = map(int,input().split()) map(int,input().split()) N Jud = 0 0 Jud Ans = 0 0 Ans Jud += comb[j-1] comb[j-1] Jud Ans += 1 1 Ans Switch = [] [] Switch S = Swi[0] Swi[0] S M = map(int,input().split()) map(int,input().split()) M L = [0,1] [0,1] L Swi = list(map(int,input().split())) list(map(int,input().split())) Swi c_list = list(itertools.product(L, repeat=N)) list(itertools.product(L, repeat=N)) c_list Swi = Switch[i] Switch[i] Swi Plist = list(map(int,input().split())) list(map(int,input().split())) Plist
import itertools
N,M = map(int,input().split())
Switch = []
for i in range(M):
    Swi = list(map(int,input().split()))
    S = Swi[0]
    Switch.append(Swi[1:S+1])
Plist = list(map(int,input().split()))
Ans = 0
L = [0,1]
c_list = list(itertools.product(L, repeat=N))
for comb in c_list:
    for i in range(M):
        Jud = 0
        Swi = Switch[i]
        for j in Swi:
            Jud += comb[j-1]
        if Jud%2 != Plist[i]:
            break
        elif i == M-1:
            Ans += 1
print(Ans)