def inpl():

    return list(map(int, input().split()))





def isAllOn(pattern):

    for i, s in enumerate(S):

        on = 0

        for k in s[1:]:

            if (pattern >> (k - 1)) % 2 == 1:

                on += 1

        # print(pattern, i, on)

        if on % 2 != P[i]:

            return False

    return True





N, M = inpl()



S = [inpl() for i in range(M)]

P = inpl()



ans = 0

for pattern in range(2**N):

    if isAllOn(pattern) is True:

        ans += 1



print(ans)

def inpl():

    return tuple(map(int, input().split()))





def getPattern(i):

    return {j for j in range(N) if (i >> j) % 2}





def isOn(pattern):

    return all(P[i] == len(pattern & S[i]) % 2 for i in range(M))





N, M = inpl()

S = []

for _ in range(M):

    tmp = inpl()

    tmp = [t - 1 for t in tmp[1:]]

    S.append(set(tmp))

P = inpl()



ans = 0

for i in range(2**N):

    pattern = getPattern(i)

    ans += int(isOn(pattern))

print(ans)

def inpl():
    return list(map(int, input().split()))


def isAllOn(pattern):
    for i, s in enumerate(S):
        on = 0
        for k in s[1:]:
            if (pattern >> (k - 1)) % 2 == 1:
                on += 1
        # print(pattern, i, on)
        if on % 2 != P[i]:
            return False
    return True


N, M = inpl()
S = [inpl() for i in range(M)]
P = inpl()
ans = 0
for pattern in range(2**N):
    if isAllOn(pattern) is True:
        ans += 1
print(ans)

def inpl():
    return tuple(map(int, input().split()))


def getPattern(i):
    return {j for j in range(N) if (i >> j) % 2}


def isOn(pattern):
    return all(P[i] == len(pattern & S[i]) % 2 for i in range(M))


N, M = inpl()
S = []
for _ in range(M):
    tmp = inpl()
    tmp = [t - 1 for t in tmp[1:]]
    S.append(set(tmp))
P = inpl()
ans = 0
for i in range(2**N):
    pattern = getPattern(i)
    ans += int(isOn(pattern))
print(ans)

-    return list(map(int, input().split())) +    return tuple(map(int, input().split())) -def isAllOn(pattern): -    for i, s in enumerate(S): -        on = 0 -        for k in s[1:]: -            if (pattern >> (k - 1)) % 2 == 1: -                on += 1 -        # print(pattern, i, on) -        if on % 2 != P[i]: -            return False -    return True +def getPattern(i): +    return {j for j in range(N) if (i >> j) % 2} + + +def isOn(pattern): +    return all(P[i] == len(pattern & S[i]) % 2 for i in range(M)) -S = [inpl() for i in range(M)] +S = [] +for _ in range(M): +    tmp = inpl() +    tmp = [t - 1 for t in tmp[1:]] +    S.append(set(tmp)) -for pattern in range(2**N): -    if isAllOn(pattern) is True: -        ans += 1 +for i in range(2**N): +    pattern = getPattern(i) +    ans += int(isOn(pattern))