
def i_input(): return int(input())


def i_map(): return map(int, input().split())


def i_list(): return list(i_map())


def i_row_list(N): return [i_list() for _ in range(N)]


def bit_search(n):

    bit_ans=[]
    for i in range(2 ** n):
        tmp=[]
        for j in range(n):
            if ((i >> j) & 1):
                tmp.append(1)
            else:
                tmp.append(0)
        bit_ans.append(tmp)
    return bit_ans

def light_check(switchpattern, lightswitches, onstat):
    cnt=0
    for i in range(len(switchpattern)):
        if switchpattern[i]==1 and lightswitches[i]==1:
            cnt+=1
    if cnt%2==onstat:
        return 1
    else:
        return 0



n,m = i_map()
kkk = i_row_list(m)
onstates=i_list()
kkk_row=[]
for i in range(m):
    tmp=[0]*n
    for j in range(len(kkk[i])):
        if j!=0:
            tmp[j-1]=1
    kkk_row.append(tmp)

switchpatterns=bit_search(n)
ans=0
for switchpattern in switchpatterns:
    cnt=0
    for i in range(len(kkk_row)):
        cnt+=light_check(switchpattern,kkk_row[i],onstates[i])
    if cnt==len(kkk_row):
        ans+=1

print(ans)