dq=du+dw---1
at the final and the initial time,v=0 (since sytem is at equliibrium)
.: for the piston=change in KE =0
.:Wgas +Wgr+Watm=0
.:Wgas=Mgx+P0A
on substituting we get Wgas=300
Also,if u write the equllibrium equations of piston at initial and final postions(or by observation),we get
initial pressure=final pressure=>process is isobaric
for isobaric process =dw=nRdT=300
also U=f/2nRT
f=5(.: oxygen diatomic)
.:U=5/2*300=750
from 1 we get ,
Q=300+750=1050J