calculate standard emf from the standard electrode potential values given in the series..
then use the nerst equation
find the K value and for all Ag n Mg the concentration will b 1.
then it's just substitution....
u don't need to use nerst equation for this.. but since u asked for it...