import time
import itertools
from heapq import heappush, heappop
import heapq
import numpy as np
import random
from collections import deque
from collections import defaultdict
from decimal import *
import bisect
import math
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, input().split())
KS = [[int(x) for x in input().split()] for _ in range(M)]
P = list(map(int, input().split()))

bit = (1 << N) - 1
cnt = 0

for i in range(bit):
    switch = [0] * N
    for j in range(N):
        isOn = (i >> j) & 1
        switch[j] = isOn

    ok = True
    for k in range(M):
        t = KS[k][1:]
        c = 0
        for l in t:
            c += switch[l - 1]

        if c % 2 != P[k - 1]:
            ok = False
            break

    if ok:
        cnt += 1

print(cnt)
