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

ks = []

for i in range(m):

    ks.append(list(map(int, input().split())))

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

ans = 0

for i in range(1<<n):   #全部分集合について

    all_flug = True

    for j in range(m):  #全電球(パターン)について

        cnt = 0

        for k in range(n):   #全スイッチについて

            # print(bin(i), k+1, ks[j][1:], (i & (1<<k)) and (k+1 in ks[j][1:]))

            if (i & (1<<k)) and (k+1 in ks[j][1:]):   #スイッチがオンかつ電球に繋がってる

                cnt += 1

        # print(bin(i), cnt, p[j])

        # print(bin(i), cnt, p[j], cnt % 2 == p[j])

        if cnt % 2 != p[j]:

            all_flug = False

            # break

    # print(bin(i), all_flug)

    if all_flug:

        ans += 1

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



s_lst = [[False] * N for _ in range(M)]

for i in range(M):

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

    for j, value in enumerate(ks):

        if j != 0:

            s_lst[i][value-1] = True

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

# print(s_lst)



ans = 0

for bit in range(2**N):

    cnt = [0] * M

    for i in range(N):

        if (bit>>i) & 1 == 1:

            for j in range(M):

                if s_lst[j][i]:

                    cnt[j] += 1

    flug = True

    for i in range(M):

        if cnt[i] % 2 != p[i]:

            flug = False

    if flug:

        ans += 1

print(ans)

n, m = list(map(int, input().split()))
ks = []
for i in range(m):
    ks.append(list(map(int, input().split())))
p = list(map(int, input().split()))
ans = 0
for i in range(1 << n):  # 全部分集合について
    all_flug = True
    for j in range(m):  # 全電球(パターン)について
        cnt = 0
        for k in range(n):  # 全スイッチについて
            # print(bin(i), k+1, ks[j][1:], (i & (1<<k)) and (k+1 in ks[j][1:]))
            if (i & (1 << k)) and (k + 1 in ks[j][1:]):  # スイッチがオンかつ電球に繋がってる
                cnt += 1
        # print(bin(i), cnt, p[j])
        # print(bin(i), cnt, p[j], cnt % 2 == p[j])
        if cnt % 2 != p[j]:
            all_flug = False
            # break
    # print(bin(i), all_flug)
    if all_flug:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))
s_lst = [[False] * N for _ in range(M)]
for i in range(M):
    ks = list(map(int, input().split()))
    for j, value in enumerate(ks):
        if j != 0:
            s_lst[i][value - 1] = True
p = list(map(int, input().split()))
# print(s_lst)
ans = 0
for bit in range(2**N):
    cnt = [0] * M
    for i in range(N):
        if (bit >> i) & 1 == 1:
            for j in range(M):
                if s_lst[j][i]:
                    cnt[j] += 1
    flug = True
    for i in range(M):
        if cnt[i] % 2 != p[i]:
            flug = False
    if flug:
        ans += 1
print(ans)

-n, m = list(map(int, input().split())) -ks = [] -for i in range(m): -    ks.append(list(map(int, input().split()))) +N, M = list(map(int, input().split())) +s_lst = [[False] * N for _ in range(M)] +for i in range(M): +    ks = list(map(int, input().split())) +    for j, value in enumerate(ks): +        if j != 0: +            s_lst[i][value - 1] = True +# print(s_lst) -for i in range(1 << n):  # 全部分集合について -    all_flug = True -    for j in range(m):  # 全電球(パターン)について -        cnt = 0 -        for k in range(n):  # 全スイッチについて -            # print(bin(i), k+1, ks[j][1:], (i & (1<<k)) and (k+1 in ks[j][1:])) -            if (i & (1 << k)) and (k + 1 in ks[j][1:]):  # スイッチがオンかつ電球に繋がってる -                cnt += 1 -        # print(bin(i), cnt, p[j]) -        # print(bin(i), cnt, p[j], cnt % 2 == p[j]) -        if cnt % 2 != p[j]: -            all_flug = False -            # break -    # print(bin(i), all_flug) -    if all_flug: +for bit in range(2**N): +    cnt = [0] * M +    for i in range(N): +        if (bit >> i) & 1 == 1: +            for j in range(M): +                if s_lst[j][i]: +                    cnt[j] += 1 +    flug = True +    for i in range(M): +        if cnt[i] % 2 != p[i]: +            flug = False +    if flug: