Work done by friction in a complicated path 

A block of mass $M$ is taken from point $A$ to point $B$ in a complex path by a force $F$ which is always tangential to the path. We also have coefficient of friction as $K$. What will be the work done by force $F$ when it reaches point $B$ from point $A$? Given that the vertical displacement from $A$ to $B$ is $h$ and the horizontal displacement from $A$ to $B$ is $l$.

In this question, I tried solving the problem using conservation of energy, we know that the total energy will remain constant. So with that, we will have,
$$\Delta U_{gravity}+W_{friction}+W_{F} = O$$ But how do you calculate the work done by friction in this case?
Moreover, in the answer, the work done by friction is only dependent on l!!
EDIT:
     1.The body is moved very slowly.
 A: To calculate the work done by friction, you multiply the friction force times the total length of the path on the surface that the mass is moved. The magnitude of the friction force on a horizontal surface is the product of the normal force on the surface, $mg$, and the coefficient of kinetic friction, which is designated $K$ in the problem, or $F_{f}=Kmg$. 
If we assume the surface upon which the mass moves is in the x-y plane, and the the z direction is the vertical displacement, h, then the length of the path for calculating the friction work would be the total distance covered by the mass on the x-y plane.
In the x-y plane a "horizontal" displacement could mean (1) a displacement along the x- axis, (2) a displacement along the y- axis or (3) a combination of both as long as it does not involve a vertical displacement. The problem statement, at least to me, is not clear exactly what the path in the x-y plane is. But based on the answer, the total distance the mass has moved on the on the x-y appears to be I, whatever path that represents.
UPDATE:
Based on the image you just added, the normal force exerted by the mass at any point along the path is $mg$cos θ where θ is the angle between the tangent to the path at any point and the horizontal. This means that only horizontal components (θ= 0) of the displacement along the path contribute to friction work. The vertical components (θ = 90) of the path do not contribute. The end result is that the friction work depends only on the horizontal displacement, $l$.
Hope this  helps. 
A: Here, at any instant of time, the normal force on the body is $mg\cos\theta$, where $\theta$ is the angle made between the downward direction and the normal force on the wedge direction. Therefore, the work done by friction on moving distance dl is $\mu mg\cos\theta.dl$. Notice, however, that $dl$ could also be written as $\frac{dI}{\cos\theta}$, where $dI$ is the horizontal path length. Hence, the cos term will cancel and on integration will give you your answer irrespective of the path.
A: In fact the answer is a general result for all particles taken slowly from one point to another when it is on any inclined surface.
The Normal reaction is given as:-$$N=mg\cos\theta$$ This relation is valid as the body is hauled up slowly so the acceleration perpendicular to the surface tends to zero.
$\theta$ is the variable angle made by the the tangent at any point on the surface with the horizontal.$$f=kmg\cos\theta$$
Work done by friction in moving the particle by a distance $ds$ along the path:-$$dW_{friction}=kmg\cos\theta ds$$
Now $$ds\cos\theta=dl$$
So $$dW_{friction}=kmgdl$$
$$W_{friction}=\int kmgdl$$
$$W_{friction}=kmgl$$
We conclude that if the object takes any random path the work done would only depend on horizontal distance between initial and final point.
EDIT 1
As you have asked about the work done by $F$ in the comment section.You can simply use work energy theorem to solve it.
$$W_{total}=\Delta K$$
$$\Delta K=0$$
$$W_{friction}+W_{gravity}+W_{F}=0$$
$$W_{F}=kmgl+mgh=mg(h+kl)$$
A: The fact that no details on path are given implies that any path should give the same answer.  Take a straight line from A to B or move horizontally and then vertically. Either way you get kmgl for the work done by friction. The work done by force F is just Fl + Fh = kmgl + mgh.  (This assumes F changes and produces no noticeable acceleration.)
A: Friction is not a force from a scalar potential.  As such the work done is path dependent so there is not enough information to answer the question.
