Answer
See the detailed answer below.
Work Step by Step
As we see in the given graph, it is a compression-isobaric process.
The work done on the gas in this process is given by
$$W=-\int_i^f PdV=-P( V_f- V_i)$$
where $( V_f-V_i\lt 0)$ is negative since the gas compresses.
Thus, the work done on the gas here is positive.
$$W=P(V_i-V_f)$$
We know, for an ideal gas, undergoes an isobaric process that
$$\dfrac{\color{red}{\bf\not} P_1V_1}{T_1}=\dfrac{\color{red}{\bf\not} P_2V_2}{T_2}$$
Hence,
$$\dfrac{V_1}{V_2}=\dfrac{T_1}{T_2}$$
where $V_1\gt V_2$, so
$$\dfrac{V_1}{V_2}=\dfrac{T_1}{T_2}\gt 1$$
So,
$$T_1\gt T_2$$
This means that during this process we need to decrease the system's temperature. Thus, heat is moved out of our system.
This also means that the final thermal energy of the system is less than the initial thermal energy of the system.
So, from all the above,
$$\boxed{E_{f,th}=E_{i,th}+W-Q}$$
See the bar chart of this equation below.
To proceed with this process, we need to:
1- Let the piston moves freely by unlocking the pin.
2- Not changing the mass above the piston to maintain the pressure constant.
3- Put the ice in contact with the bottom of the cylinder.
---