Multiply the first row by -g/2 and add to the second row. The new second row is
... [0, -2g, 3-g/2, 5-2g, h-7g/2]
Multiply the first row by -1 and add to the third row. The new third row is
... [0, 1, 8, k-4, -4]
Now, multiply the new second row by 1/(2g) and add to the third row. The new third row is ...
... [0, 0, 8+(3-g/2)/(2g), k-4+(5-2g)/(2g), -4+(h-7g/2)/(2g)]
This third row simplifies to
... [0, 0, (6+31g)/4g, (5-10g+2gk)/(2g), (2h-23g)/(4g)]
Normalizing each row so its pivot element is 1 and finishing the row operations necessary to leave the left three columns a diagonal matrix puts terms in the right two columns that have 6+31g in their denominator.
The equations necessary to make the system consistent appear to be
... g ≠ 0
... 6 + 31g ≠ 0