By the first law of thermodynamics states when heat is supplied to a system the internal energy change of the system is the difference of energy applied to the system and the work done by the system.
In equation form, it is
Delta U = Q -W
Since 50J is work done on the system,
The work done by the system is opposite in magnitude. Hence -50J
With 30J supplied the change in internal energy = 30-(-50) = 80J