n, m = list(map(int, input().split()))
k = []

for i in range(m):
    ki = list(map(int, input().split()))
    s = [0] * n
    for j in range(1, len(ki)):
        s[ki[j]-1] = 1

    k.append(int("".join(map(str, s)), 2))

p = list(map(int, input().split()))

def count1s(n):
    cnt = 0
    while n > 0:
        cnt += n & 1
        n >>= 1

    return cnt

cnt = 0
for i in range(2**n):
    sol = True
    for j in range(m):
        if count1s(i & k[j]) % 2 == p[j]:
            pass
        else:
            sol = False
            break

    if sol:
        cnt += 1

print(cnt) n, m = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split m k = [] k [] for i in range(m):
    ki = list(map(int, input().split()))
    s = [0] * n
    for j in range(1, len(ki)):
        s[ki[j]-1] = 1

    k.append(int("".join(map(str, s)), 2)) i range(m) range m ki = list(map(int, input().split())) ki list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split s = [0] * n s [0] * n [0] 0 n for j in range(1, len(ki)):
        s[ki[j]-1] = 1

     j range(1, len(ki)) range 1 len(ki) len ki s[ki[j]-1] = 1 s[ki[j]-1] s ki[j]-1 ki[j] ki j 1 1 k.append(int("".join(map(str, s)), 2)) k.append k append int("".join(map(str, s)), 2) int "".join(map(str, s)) "".join "" join map(str, s) map str s 2 p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def count1s(n):
    cnt = 0
    while n > 0:
        cnt += n & 1
        n >>= 1

    return cnt count1s cnt = 0 cnt 0 while n > 0:
        cnt += n & 1
        n >>= 1

     n > 0 n 0 cnt += n & 1 cnt n & 1 n 1 n >>= 1 n 1 return cnt cnt n n cnt = 0 cnt 0 for i in range(2**n):
    sol = True
    for j in range(m):
        if count1s(i & k[j]) % 2 == p[j]:
            pass
        else:
            sol = False
            break

    if sol:
        cnt += 1 i range(2**n) range 2**n 2 n sol = True sol True for j in range(m):
        if count1s(i & k[j]) % 2 == p[j]:
            pass
        else:
            sol = False
            break

     j range(m) range m if count1s(i & k[j]) % 2 == p[j]:
            pass
        else:
            sol = False
            break

     count1s(i & k[j]) % 2 == p[j] count1s(i & k[j]) % 2 count1s(i & k[j]) count1s i & k[j] i k[j] k j 2 p[j] p j sol = False sol False break if sol:
        cnt += 1 sol cnt += 1 cnt 1 print(cnt) print cnt sol = True True sol m = list(map(int, input().split())) list(map(int, input().split())) m def count1s(n):
    cnt = 0
    while n > 0:
        cnt += n & 1
        n >>= 1

    return cnt def count1s(n):
    cnt = 0
    while n > 0:
        cnt += n & 1
        n >>= 1

    return cnt count1s cnt += 1 1 cnt sol = False False sol s = [0] * n [0] * n s k = [] [] k n, m = list(map(int, input().split())) list(map(int, input().split())) n p = list(map(int, input().split())) list(map(int, input().split())) p ki = list(map(int, input().split())) list(map(int, input().split())) ki cnt = 0 0 cnt
n, m = list(map(int, input().split()))
k = []

for i in range(m):
    ki = list(map(int, input().split()))
    s = [0] * n
    for j in range(1, len(ki)):
        s[ki[j]-1] = 1

    k.append(int("".join(map(str, s)), 2))

p = list(map(int, input().split()))

def count1s(n):
    cnt = 0
    while n > 0:
        cnt += n & 1
        n >>= 1

    return cnt

cnt = 0
for i in range(2**n):
    sol = True
    for j in range(m):
        if count1s(i & k[j]) % 2 == p[j]:
            pass
        else:
            sol = False
            break

    if sol:
        cnt += 1

print(cnt)