# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n, m = MI()
    K = []
    S = {}
    for i in range(m):
        l = LI()
        k = l[0]
        s = l[1:]
        # print(k, s)
        K.append(k)
        S[i] = s
    P = LI()

    ans = 0
    # print('aaa', n, m)
    for i in range(pow(2, n)):
        # print(bin(i))
        for v in range(m):
            sv = S[v]
            p = P[v]
            sm = 0
            # print('  sv p', sv, p)

            for j in range(m):
                # print('  i >> j', i >> j, i, j)
                if 1 & (i >> j):
                    if j+1 in sv:
                        sm += 1

            # print('  sm', sm)
            if sm % 2 == p:
                continue
                # pass
            else:
                # print('not p')
                break
        else:
            # print('ans+1')
            ans += 1
    print(ans)



if __name__ == '__main__':
    solve()
