import numpy as np



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

S = []

for _ in range(m):

    *a, = list(map(int, input().split()))

    l = a[1:]

    S.append(l)

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



ans = 0

for i in range(2**n):

    tmp = np.array([i >> j & 1 for j in range(n)])

    if p == [sum(tmp[np.array(s)-1]) % 2 for s in S]:

        ans += 1

print(ans)

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

S = []

for _ in range(m):

    S.append(list(map(int, input().split()))[1:])

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



ans = 0

for i in range(2**n):

    switch = [i >> j & 1 for j in range(n)]

    c = 0

    for k, s in enumerate(S):

        count = 0

        for s1 in s:

            if switch[s1-1]:

                count += 1

        if count % 2 == p[k]:

            c += 1

    if m == c:

        ans += 1

print(ans)

import numpy as np

n, m = list(map(int, input().split()))
S = []
for _ in range(m):
    (*a,) = list(map(int, input().split()))
    l = a[1:]
    S.append(l)
(*p,) = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    tmp = np.array([i >> j & 1 for j in range(n)])
    if p == [sum(tmp[np.array(s) - 1]) % 2 for s in S]:
        ans += 1
print(ans)

n, m = list(map(int, input().split()))
S = []
for _ in range(m):
    S.append(list(map(int, input().split()))[1:])
(*p,) = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    switch = [i >> j & 1 for j in range(n)]
    c = 0
    for k, s in enumerate(S):
        count = 0
        for s1 in s:
            if switch[s1 - 1]:
                count += 1
        if count % 2 == p[k]:
            c += 1
    if m == c:
        ans += 1
print(ans)

-import numpy as np - -    (*a,) = list(map(int, input().split())) -    l = a[1:] -    S.append(l) +    S.append(list(map(int, input().split()))[1:]) -    tmp = np.array([i >> j & 1 for j in range(n)]) -    if p == [sum(tmp[np.array(s) - 1]) % 2 for s in S]: +    switch = [i >> j & 1 for j in range(n)] +    c = 0 +    for k, s in enumerate(S): +        count = 0 +        for s1 in s: +            if switch[s1 - 1]: +                count += 1 +        if count % 2 == p[k]: +            c += 1 +    if m == c: