Heat and Work Under Different Constraints