N,M = list(map(int,input().split()))

s = []

for i in range(M):

    dp = [0]*(N)

    k,*tmp = list(map(int,input().split()))

    for j in tmp:dp[j-1]=1

    s.append(dp)

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

ans = 0

for i in range(1<<N):

    tmp = 0

    dp = [0]*M

    for I in range(M):

        for j in range(N):

            t = i>>j&1

            dp[I] += s[I][j] * t

    for e,i in enumerate(dp):

        dp[e] = i%2

    if dp == p:

        ans+=1

print(ans)







N,M = list(map(int, input().split()))

S = []

for i in range(M):

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

    t = 0

    for j in tmp[1:]:

        t += 1 << (j - 1)

    S.append(t)

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



ans = 0

for i in range(1 << N):

    f = 0

    for s, p in zip(S, P):

        t = i & s

        c = bin(t).count('1') % 2

        if c == p:f+=1

            

    if f == M:

        ans += 1

print(ans)

N, M = list(map(int, input().split()))
s = []
for i in range(M):
    dp = [0] * (N)
    k, *tmp = list(map(int, input().split()))
    for j in tmp:
        dp[j - 1] = 1
    s.append(dp)
p = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
    tmp = 0
    dp = [0] * M
    for I in range(M):
        for j in range(N):
            t = i >> j & 1
            dp[I] += s[I][j] * t
    for e, i in enumerate(dp):
        dp[e] = i % 2
    if dp == p:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))
S = []
for i in range(M):
    tmp = list(map(int, input().split()))
    t = 0
    for j in tmp[1:]:
        t += 1 << (j - 1)
    S.append(t)
P = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
    f = 0
    for s, p in zip(S, P):
        t = i & s
        c = bin(t).count("1") % 2
        if c == p:
            f += 1
    if f == M:
        ans += 1
print(ans)

-s = [] +S = [] -    dp = [0] * (N) -    k, *tmp = list(map(int, input().split())) -    for j in tmp: -        dp[j - 1] = 1 -    s.append(dp) -p = list(map(int, input().split())) +    tmp = list(map(int, input().split())) +    t = 0 +    for j in tmp[1:]: +        t += 1 << (j - 1) +    S.append(t) +P = list(map(int, input().split())) -    tmp = 0 -    dp = [0] * M -    for I in range(M): -        for j in range(N): -            t = i >> j & 1 -            dp[I] += s[I][j] * t -    for e, i in enumerate(dp): -        dp[e] = i % 2 -    if dp == p: +    f = 0 +    for s, p in zip(S, P): +        t = i & s +        c = bin(t).count("1") % 2 +        if c == p: +            f += 1 +    if f == M: