def resolve():
    N, M = map(int, input().split())
    S = [tuple(map(int, input().split()))[1:] for _ in range(M)]
    P = tuple(map(int, input().split()))
    ans = 0

    for c in range(2**N):
        flg_list = [False]*M
        for i, s_l in enumerate(S):
            cnt = 0
            for s in s_l:
                if c & (s-1):
                    cnt += 1

            if cnt % 2 == P[i]:
                flg_list[i] = True

        if all(flg_list):
            ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()