Is the exam exercise in contradiction with itself?
"Then I got really confused by the voltmeter readings. If the voltmeter shows 15V when switch P is open, that means that −IgR6=15V, but in the second state, when P is closed, we have −IgR6=20V. How can that be?"

You are assuming the voltage across Ig is zero.  It could be but is not required to be.

A resistor in series with a current source never changes anything as the voltage across the current source will always adjust itself to compensate.

I would suggest redrawing the circuit with a resistor in place of the Voltmeter (10k).

short out R4 and replace R5 with a 3k resistor.

Personally I would also draw the circuit up the other way with the positive side of E1 and E2 upwards.  These will help in understanding the circuit better.