Optimal control of damping rotation of a rigid body using fly wheels with friction