# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def brute_force():
    N, M = map(int, input().split())
    lamps = [list(map(lambda x:int(x)-1, input().split()))[1:]
             for _ in range(M)]
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1 << N):
        ok = True
        for r in range(M):
            on_sum = 0
            for j in range(M):
                if i >> j & 1 and j in lamps[r]:
                    on_sum += 1
            if on_sum % 2 != p[r]:
                ok = False
                break
        if ok:
            ans += 1
    print(ans)


brute_force()
