import numpy as np

import itertools as ittr



def test_switch(e_balls, sw, p):

    for i, e_ball in enumerate(e_balls):

        eb = np.asarray(e_ball)

        si = sw[eb - 1]

        

        if p[i] != (np.sum(si == 1) % 2):

            return False

    

    return True



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



e_balls = []



for m in range(M):

    i = input().split()

    s = [int(si) for si in i[1:]]

    e_balls.append(s[:])



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



cnt = 0



for sw in ittr.product([0, 1], repeat = N):

    if test_switch(e_balls, np.array(sw), p):

        cnt += 1



print(cnt)
import numpy as np

import itertools as ittr



def test_switch(e_balls, sw, p):

    for i, e_ball in enumerate(e_balls):

        si = sw[e_ball - 1]

        

        if p[i] != (np.sum(si == 1) % 2):

            return False

    

    return True



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



e_balls = []



for m in range(M):

    i = input().split()

    s = [int(si) for si in i[1:]]

    e_balls.append(np.asarray(s))



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



cnt = 0



for sw in ittr.product([0, 1], repeat = N):

    if test_switch(e_balls, np.array(sw), p):

        cnt += 1



print(cnt)
import numpy as np
import itertools as ittr


def test_switch(e_balls, sw, p):
    for i, e_ball in enumerate(e_balls):
        eb = np.asarray(e_ball)
        si = sw[eb - 1]
        if p[i] != (np.sum(si == 1) % 2):
            return False
    return True


N, M = list(map(int, input().split()))
e_balls = []
for m in range(M):
    i = input().split()
    s = [int(si) for si in i[1:]]
    e_balls.append(s[:])
p = [int(pi) for pi in input().split()]
cnt = 0
for sw in ittr.product([0, 1], repeat=N):
    if test_switch(e_balls, np.array(sw), p):
        cnt += 1
print(cnt)

import numpy as np
import itertools as ittr


def test_switch(e_balls, sw, p):
    for i, e_ball in enumerate(e_balls):
        si = sw[e_ball - 1]
        if p[i] != (np.sum(si == 1) % 2):
            return False
    return True


N, M = list(map(int, input().split()))
e_balls = []
for m in range(M):
    i = input().split()
    s = [int(si) for si in i[1:]]
    e_balls.append(np.asarray(s))
p = [int(pi) for pi in input().split()]
cnt = 0
for sw in ittr.product([0, 1], repeat=N):
    if test_switch(e_balls, np.array(sw), p):
        cnt += 1
print(cnt)

-        eb = np.asarray(e_ball) -        si = sw[eb - 1] +        si = sw[e_ball - 1] -    e_balls.append(s[:]) +    e_balls.append(np.asarray(s))