N,M=map(int,input().split())
s = []
for _ in range(M):
    s.append(list(map(lambda x:int(x)-1,input().split()))[1:])
p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    fl = True
    for j in range(M):
        cnt = 0
        for sw in s[j]:
            if (i >> sw) & 1:
                cnt += 1
        if cnt % 2 != p[j]:
            fl = False
            break
    if fl:
        ans += 1
print(ans) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M s = [] s [] for _ in range(M):
    s.append(list(map(lambda x:int(x)-1,input().split()))[1:]) _ range(M) range M s.append(list(map(lambda x:int(x)-1,input().split()))[1:]) s.append s append list(map(lambda x:int(x)-1,input().split()))[1:] (map(lambda x:int(x)-1,input().split())) list map(lambda x:int(x)-1,input().split()) map lambda x:int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split 1: 1 p = list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans = 0 ans 0 for i in range(2**N):
    fl = True
    for j in range(M):
        cnt = 0
        for sw in s[j]:
            if (i >> sw) & 1:
                cnt += 1
        if cnt % 2 != p[j]:
            fl = False
            break
    if fl:
        ans += 1 i range(2**N) range 2**N 2 N fl = True fl True for j in range(M):
        cnt = 0
        for sw in s[j]:
            if (i >> sw) & 1:
                cnt += 1
        if cnt % 2 != p[j]:
            fl = False
            break
     j range(M) range M cnt = 0 cnt 0 for sw in s[j]:
            if (i >> sw) & 1:
                cnt += 1
         sw s[j] s j if (i >> sw) & 1:
                cnt += 1
         (i >> sw) & 1 i >> sw i sw 1 cnt += 1 cnt 1 if cnt % 2 != p[j]:
            fl = False
            break
     cnt % 2 != p[j] cnt % 2 cnt 2 p[j] p j fl = False fl False break if fl:
        ans += 1 fl ans += 1 ans 1 print(ans) print ans N,M=map(int,input().split()) map(int,input().split()) N cnt += 1 1 cnt ans += 1 1 ans M=map(int,input().split()) map(int,input().split()) M s = [] [] s fl = False False fl cnt = 0 0 cnt p = list(map(int,input().split())) list(map(int,input().split())) p ans = 0 0 ans fl = True True fl
N,M=map(int,input().split())
s = []
for _ in range(M):
    s.append(list(map(lambda x:int(x)-1,input().split()))[1:])
p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    fl = True
    for j in range(M):
        cnt = 0
        for sw in s[j]:
            if (i >> sw) & 1:
                cnt += 1
        if cnt % 2 != p[j]:
            fl = False
            break
    if fl:
        ans += 1
print(ans)