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]) )
    print("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()


### FIXED CODE ###

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)

# 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

# # from itertools import accumulate
# # from collections import deque
# import random


def main():
    n,m = map(int, input().split()) # n represents switch, m represents lights
    lights=[]
    for i in range(m):
        ll=list(map(int, input().split()))
        lights.append(ll[1:])
    p = list(map(int, input().split()))
    eprint(lights)
    # eprint(s)
    # l=s
    # l[1]=[]
    # eprint(l,s)
    
    # cnt_ans=0
    ans=0
    for case in range((1<<n)):
        eprint(bin(case))
        # cnt_switch_on = 0
        ii=0
        f_flag=0
        for light in lights:
            cnt_on=0
            for i in light:
                if (case>>(i-1))&1:
                    cnt_on+=1
            eprint(cnt_on,p[ii])
            if  cnt_on%2!=p[ii]:
                f_flag=1
            ii+=1
        if f_flag==0:
            ans+=1
    print(ans)

        
    #     for i in range(n):
    #         if (case>>i)&1:
    #             cnt_switch_on +=1
    #             eprint("cnt_switch_on",cnt_switch_on)
    #     f_flag=0
    #     for light in range(m):
    #         if cnt_switch_on % 2 == p[light]:
    #             eprint("剰余",cnt_switch_on % 2,"p",p[light])
    #         else:
    #             f_flag=1
    #     if f_flag==0:
    #         cnt_ans+=1
    #     eprint("cnt_ans",cnt_ans)
    
    # print(cnt_ans)


    
    
if __name__ == '__main__':
    main()