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

s = [[int(i) for i in input().split()] for j in range(M)]

p = [int(i) for i in input().split()]



ans = 0

for i in range(2**N):

    switch = [0]*N

    for j in range(N):

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

            switch[j] += 1

    on = 0

    for k in range(M):

        count = 0

        for l in range(1,s[k][0]+1):

            if switch[s[k][l]-1] == 1:

                count += 1

        if count % 2 == p[k]:

            on += 1

    if on == M:

        ans += 1

    

print(ans)

from itertools import product

import sys

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines



def main():

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

    S = [[int(i) for i in readline().split()] for _ in range(M)]

    P = [int(i) for i in readline().split()]



    ans = 0

    A = [[0, 1] for _ in range(N)]

    for pattern in product(*A):

        on = []

        for s in S:

            tmp = 0

            for i in range(s[0]):

                tmp += pattern[s[i+1]-1]

            on.append(tmp % 2)



        if on == P:

            ans += 1



    print(ans)





if __name__ == "__main__":

    main()

N, M = list(map(int, input().split()))
s = [[int(i) for i in input().split()] for j in range(M)]
p = [int(i) for i in input().split()]
ans = 0
for i in range(2**N):
    switch = [0] * N
    for j in range(N):
        if (i >> j) & 1:
            switch[j] += 1
    on = 0
    for k in range(M):
        count = 0
        for l in range(1, s[k][0] + 1):
            if switch[s[k][l] - 1] == 1:
                count += 1
        if count % 2 == p[k]:
            on += 1
    if on == M:
        ans += 1
print(ans)

from itertools import product
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N, M = list(map(int, readline().split()))
    S = [[int(i) for i in readline().split()] for _ in range(M)]
    P = [int(i) for i in readline().split()]
    ans = 0
    A = [[0, 1] for _ in range(N)]
    for pattern in product(*A):
        on = []
        for s in S:
            tmp = 0
            for i in range(s[0]):
                tmp += pattern[s[i + 1] - 1]
            on.append(tmp % 2)
        if on == P:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-N, M = list(map(int, input().split())) -s = [[int(i) for i in input().split()] for j in range(M)] -p = [int(i) for i in input().split()] -ans = 0 -for i in range(2**N): -    switch = [0] * N -    for j in range(N): -        if (i >> j) & 1: -            switch[j] += 1 -    on = 0 -    for k in range(M): -        count = 0 -        for l in range(1, s[k][0] + 1): -            if switch[s[k][l] - 1] == 1: -                count += 1 -        if count % 2 == p[k]: -            on += 1 -    if on == M: -        ans += 1 -print(ans) +from itertools import product +import sys + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines + + +def main(): +    N, M = list(map(int, readline().split())) +    S = [[int(i) for i in readline().split()] for _ in range(M)] +    P = [int(i) for i in readline().split()] +    ans = 0 +    A = [[0, 1] for _ in range(N)] +    for pattern in product(*A): +        on = [] +        for s in S: +            tmp = 0 +            for i in range(s[0]): +                tmp += pattern[s[i + 1] - 1] +            on.append(tmp % 2) +        if on == P: +            ans += 1 +    print(ans) + + +if __name__ == "__main__": +    main()