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

K = [0] * M

for i in range(M):

  K[i] = list(map(int, input().split()))

  K[i].pop(0)

#print(K)



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



ans = 0

for i in range(2 ** N):#最大1000

  now = [0] * (N + 1)

  x = 1

  for j in range(N):#最大10

    if ((i >> j) & 1):

      now[j + 1] = 1

  for k in range(M):# 10 * 10

    now2 = 0

    for a in K[k]:

      if now[a] == 1:

        now2 += 1

    if now2 % 2 != p[k]:

      x = 0

  ans += x

  

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

K = [0] * M

for i in range(M):

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

  K[i] = S[1:]

  

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

#print(K)



count = 0

for i in range(2 ** N):#1024

  on = [0] * N

  ans = [0] * M

  ans2 = [1] * M

  for j in range(N):#10

    if ((i >> j) & 1):

      on[j] = 1

  #print(on)

  for k in range(M):#10

    now = 0

    for l in K[k]:

      if on[l - 1] == 1:

        now += 1

    if now % 2 == P[k]:

      ans[k] = 1

  #print(on, ans)

  if ans == ans2:

    count += 1



print(count)
N, M = list(map(int, input().split()))
K = [0] * M
for i in range(M):
    K[i] = list(map(int, input().split()))
    K[i].pop(0)
# print(K)
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):  # 最大1000
    now = [0] * (N + 1)
    x = 1
    for j in range(N):  # 最大10
        if (i >> j) & 1:
            now[j + 1] = 1
    for k in range(M):  # 10 * 10
        now2 = 0
        for a in K[k]:
            if now[a] == 1:
                now2 += 1
        if now2 % 2 != p[k]:
            x = 0
    ans += x
print(ans)

N, M = list(map(int, input().split()))
K = [0] * M
for i in range(M):
    S = list(map(int, input().split()))
    K[i] = S[1:]
P = list(map(int, input().split()))
# print(K)
count = 0
for i in range(2**N):  # 1024
    on = [0] * N
    ans = [0] * M
    ans2 = [1] * M
    for j in range(N):  # 10
        if (i >> j) & 1:
            on[j] = 1
    # print(on)
    for k in range(M):  # 10
        now = 0
        for l in K[k]:
            if on[l - 1] == 1:
                now += 1
        if now % 2 == P[k]:
            ans[k] = 1
    # print(on, ans)
    if ans == ans2:
        count += 1
print(count)

-    K[i] = list(map(int, input().split())) -    K[i].pop(0) +    S = list(map(int, input().split())) +    K[i] = S[1:] +P = list(map(int, input().split())) -p = list(map(int, input().split())) -ans = 0 -for i in range(2**N):  # 最大1000 -    now = [0] * (N + 1) -    x = 1 -    for j in range(N):  # 最大10 +count = 0 +for i in range(2**N):  # 1024 +    on = [0] * N +    ans = [0] * M +    ans2 = [1] * M +    for j in range(N):  # 10 -            now[j + 1] = 1 -    for k in range(M):  # 10 * 10 -        now2 = 0 -        for a in K[k]: -            if now[a] == 1: -                now2 += 1 -        if now2 % 2 != p[k]: -            x = 0 -    ans += x -print(ans) +            on[j] = 1 +    # print(on) +    for k in range(M):  # 10 +        now = 0 +        for l in K[k]: +            if on[l - 1] == 1: +                now += 1 +        if now % 2 == P[k]: +            ans[k] = 1 +    # print(on, ans) +    if ans == ans2: +        count += 1 +print(count)