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

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

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



switch_conbs = []

for i in range(2 ** N):

    conb = bin(i)[2:].zfill(N)

    switch_conbs.append(list(map(int, list(conb))))



for i, light in enumerate(lights):

    temp = []

    for switch_conb in switch_conbs:

        s = 0

        for v in light[1:]:

            s += switch_conb[v - 1]

        if s % 2 != p_values[i]:

            temp.append(switch_conb)

    

    for l in temp:

        switch_conbs.pop(switch_conbs.index(l))



print((len(switch_conbs)))
import sys

readline = sys.stdin.readline



def main():

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

    S = []

    for _ in range(M):

        _, *s = list(map(int, readline().rstrip().split()))

        S.append(set(s))

    P = list(map(int, readline().rstrip().split()))



    ans = 0

    for i in range(2**N):

        b = bin(i)[2:].zfill((N))

        b = set([i+1 for i, e in enumerate(b) if e == '1'])

        flg = True

        for j, s in enumerate(S):

            if len(s&b) % 2 != P[j]:

                flg = False

                break

        if flg:

            ans += 1

    

    print(ans)



if __name__ == '__main__':

    main()
N, M = list(map(int, input().split()))
lights = [list(map(int, input().split())) for _ in range(M)]
p_values = list(map(int, input().split()))
switch_conbs = []
for i in range(2**N):
    conb = bin(i)[2:].zfill(N)
    switch_conbs.append(list(map(int, list(conb))))
for i, light in enumerate(lights):
    temp = []
    for switch_conb in switch_conbs:
        s = 0
        for v in light[1:]:
            s += switch_conb[v - 1]
        if s % 2 != p_values[i]:
            temp.append(switch_conb)
    for l in temp:
        switch_conbs.pop(switch_conbs.index(l))
print((len(switch_conbs)))

import sys

readline = sys.stdin.readline


def main():
    N, M = list(map(int, readline().rstrip().split()))
    S = []
    for _ in range(M):
        _, *s = list(map(int, readline().rstrip().split()))
        S.append(set(s))
    P = list(map(int, readline().rstrip().split()))
    ans = 0
    for i in range(2**N):
        b = bin(i)[2:].zfill((N))
        b = set([i + 1 for i, e in enumerate(b) if e == "1"])
        flg = True
        for j, s in enumerate(S):
            if len(s & b) % 2 != P[j]:
                flg = False
                break
        if flg:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-N, M = list(map(int, input().split())) -lights = [list(map(int, input().split())) for _ in range(M)] -p_values = list(map(int, input().split())) -switch_conbs = [] -for i in range(2**N): -    conb = bin(i)[2:].zfill(N) -    switch_conbs.append(list(map(int, list(conb)))) -for i, light in enumerate(lights): -    temp = [] -    for switch_conb in switch_conbs: -        s = 0 -        for v in light[1:]: -            s += switch_conb[v - 1] -        if s % 2 != p_values[i]: -            temp.append(switch_conb) -    for l in temp: -        switch_conbs.pop(switch_conbs.index(l)) -print((len(switch_conbs))) +import sys + +readline = sys.stdin.readline + + +def main(): +    N, M = list(map(int, readline().rstrip().split())) +    S = [] +    for _ in range(M): +        _, *s = list(map(int, readline().rstrip().split())) +        S.append(set(s)) +    P = list(map(int, readline().rstrip().split())) +    ans = 0 +    for i in range(2**N): +        b = bin(i)[2:].zfill((N)) +        b = set([i + 1 for i, e in enumerate(b) if e == "1"]) +        flg = True +        for j, s in enumerate(S): +            if len(s & b) % 2 != P[j]: +                flg = False +                break +        if flg: +            ans += 1 +    print(ans) + + +if __name__ == "__main__": +    main()