from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    # n,m の先行受け取り
    n,m = map(int, input().split())
    # コンテナの準備
    k=[0 for i in range(n)]     # それぞれの電球(light)に繋がれたスイッチ(swuitch)の個数を表す
    # s=[0 for i in range(n)]     # それぞれの電球(light)に繋がれている「スイッチ(switch)」を表す
    
    S=[ [] for i in range(m)]
    for i in range(m):
        S[i]=[ 0 for i in range( k[i] ) ]

    # 入力
    for i in range(m):
        l = list(map(int, input().split()))
        k[i] = l[0]
        ll=l[1:]
        for j in range(len(ll)):
            ll[j]=ll[j]-1
        S[i] = ll
    p = list(map(int, input().split()))

    # 出力
    eprint()
    # print(n,m)
    eprint("num of Switch : " + str(n) + "    num of Light : " + str(m))
    for i in range(m):
        # print(k[i],S[i])
        eprint("k[%d]: %d      S[%d]: " % (i,k[i],i ) + str(S[i]) )
    eprint("p: "+ str(p))

    # 処理
    cnt_state_whereLightIsTurnedOn=0
    
    for state in range(2**n):   # stateは状態(ステート)を表す整数
        failure_flag=0
        for index in range(m):  # indexは電灯の番号を表すインデックス
            cnt=0
            for i in range(k[index]): # i is the "uniform_number" of Switches
                if (state>>S[index][i] & 1)==1 :
                    cnt+=1
                    
            if cnt%2==p[index]:
                # failure_flag=0
                # cnt_state_whereLightIsTurnedOn+=1
                continue
            else:
                failure_flag=1
                break
                print(cnt_state_whereLightIsTurnedOn)
        if failure_flag==0:
            cnt_state_whereLightIsTurnedOn+=1
        else:
            continue
        
    print(cnt_state_whereLightIsTurnedOn)
    return

if __name__ == '__main__':
    main()
