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

S = [list(map(int,input().split())) for _ in range(M)]

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

ans = 0

for i in range(2**N):

  count = 0

  on_or_off = [0]*M

  for j in range(N):

    if (i>>j)&1:

      for k in range(M):

        if j+1 in S[k][1:]:

          on_or_off[k] += 1

  for l in range(M):

    if on_or_off[l]%2 == P[l]:

      count += 1

  if count == M:

    ans += 1

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

ks = [list(map(int,input().split())) for _ in range(M)]

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

ans = 0



for i in range(2**N):

  on_or_off = [0]*M

  for j in range(N):

    if (i>>j)&1:

      for k in range(M):

        if j+1 in ks[k][1:]:

          on_or_off[k] += 1

  cnt = 0

  for l in range(M):

    if on_or_off[l]%2 == P[l]:

      cnt += 1

  if cnt == M:

    ans += 1

print(ans)
N, M = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
    count = 0
    on_or_off = [0] * M
    for j in range(N):
        if (i >> j) & 1:
            for k in range(M):
                if j + 1 in S[k][1:]:
                    on_or_off[k] += 1
    for l in range(M):
        if on_or_off[l] % 2 == P[l]:
            count += 1
    if count == M:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))
ks = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
    on_or_off = [0] * M
    for j in range(N):
        if (i >> j) & 1:
            for k in range(M):
                if j + 1 in ks[k][1:]:
                    on_or_off[k] += 1
    cnt = 0
    for l in range(M):
        if on_or_off[l] % 2 == P[l]:
            cnt += 1
    if cnt == M:
        ans += 1
print(ans)

-S = [list(map(int, input().split())) for _ in range(M)] +ks = [list(map(int, input().split())) for _ in range(M)] -    count = 0 -                if j + 1 in S[k][1:]: +                if j + 1 in ks[k][1:]: +    cnt = 0 -            count += 1 -    if count == M: +            cnt += 1 +    if cnt == M: