def switches(M, array, P):
    count = 0
    for i in range(0,2**N):
        flag = 0
        for j in range(M):
            sum = 0
            for k in range(1,array[j][0]+1):
                if format(i, '0'+str(N)+'b')[array[j][k]-1] == '1':
                    sum += 1
            
            if sum%2 == P[j] and flag == 0:
                flag += 1
            elif sum%2 == P[j] and flag == 1:
                flag += 1
            
        if flag == M:
            count += 1

    return count


if __name__ == "__main__":
    N,M = map(int, input().split())
    array = []
    for i in range(M):
        array.append(list(map(int, input().strip().split())))
    P = list(map(int, input().strip().split()))
    print(switches(M,array,P))
