def IntToState(X, N):
    ret = []
    bina = bin(X)
    for i in range(2, len(bina)):
        ret.append(int(bina[i]))
    while len(ret) <= N:
        ret.insert(0,0)
    return ret

def solve():
    N, M = [int(_) for _ in raw_input().split()]
    SK = []
    for i in range(M):
        SKi = [int(_) for _ in raw_input().split()]
        SK.append(SKi)
    p = [int(_) for _ in raw_input().split()]
    ans = 0
    MAX_CASE = 1<<N
    for i in range (MAX_CASE):
        state = IntToState(i, N)
        satisfi = True
        for j in range(M):
            tmp_sum = 0
            for k in range(1, SK[j][0] + 1):
                tmp_sum += state[SK[j][k]]
            if tmp_sum % 2 != p[j]:
                satisfi = False
                break
        if satisfi:
            ans += 1
    print ans

if __name__ == '__main__':
    solve()
