N, M = map(int, input().split())

l = []

for _ in range(M):
    k, *s = map(int, input().split())
    l.append(s)

*P, = map(int, input().split())
count = 0
for i in range(2**N):
    switch = ["on"] * N
    m = [False]*M
    for j in range(N):
        if (i>>j) & 1:
            switch[j] = "off"

    switch_count = 0
    n = 0
    #onと繋がっているスイッチを探す。
    for switch_element in switch:
        if switch_element == "on":
            switch_index = n + 1
            for l_element in l:
                if switch_index in l_element:
                    for ind in range(1,len(switch)+1):
                        if ind in l_element and (switch[ind-1] == 'on'):
                            switch_count = switch_count + 1
                    if switch_count%2==P[l.index(l_element)]:
                        m[l.index(l_element)] = True
        n = n + 1
    
    if False in m:
        continue
    count = count + 1
        

print(count)