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

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

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

c = 0

a = 0

for a in range(2**n):

  a2 = format(a, 'b').zfill(n)

  d = 0

  for i in range(m):

    o = 0

    for j in range(S[i][0]):

      o += int(a2[S[i][j+1]-1])

    if o % 2 == P[i]:

      d += 1

  if d == m:

    c += 1

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

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

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



ans = 0



for i in range(2**N):

    flag = True

    for k in range(M):

        on = 0

        

        for j in range(B[k][0]):

            if i>>(B[k][j+1]-1) & 1:

                on += 1

        

        if on%2 != P[k]:

            flag = False

            

    if flag:

        ans += 1

        

print(ans)
n, m = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(m)]
P = list(map(int, input().split()))
c = 0
a = 0
for a in range(2**n):
    a2 = format(a, "b").zfill(n)
    d = 0
    for i in range(m):
        o = 0
        for j in range(S[i][0]):
            o += int(a2[S[i][j + 1] - 1])
        if o % 2 == P[i]:
            d += 1
    if d == m:
        c += 1
print(c)

N, M = list(map(int, input().split()))
B = [tuple(map(int, input().split())) for _ in range(M)]
P = tuple(map(int, input().split()))
ans = 0
for i in range(2**N):
    flag = True
    for k in range(M):
        on = 0
        for j in range(B[k][0]):
            if i >> (B[k][j + 1] - 1) & 1:
                on += 1
        if on % 2 != P[k]:
            flag = False
    if flag:
        ans += 1
print(ans)

-n, m = list(map(int, input().split())) -S = [list(map(int, input().split())) for i in range(m)] -P = list(map(int, input().split())) -c = 0 -a = 0 -for a in range(2**n): -    a2 = format(a, "b").zfill(n) -    d = 0 -    for i in range(m): -        o = 0 -        for j in range(S[i][0]): -            o += int(a2[S[i][j + 1] - 1]) -        if o % 2 == P[i]: -            d += 1 -    if d == m: -        c += 1 -print(c) +N, M = list(map(int, input().split())) +B = [tuple(map(int, input().split())) for _ in range(M)] +P = tuple(map(int, input().split())) +ans = 0 +for i in range(2**N): +    flag = True +    for k in range(M): +        on = 0 +        for j in range(B[k][0]): +            if i >> (B[k][j + 1] - 1) & 1: +                on += 1 +        if on % 2 != P[k]: +            flag = False +    if flag: +        ans += 1 +print(ans)