Dispute over order of authors
There is a fair option available. The professor could have insisted that both M and G could be first author. I have seen in research follows like this:

M*, G*, P or G*, M*, P

* Both the authors contributed equally to this work.

Your present authorship order: P, G, M is really unfair for both of you (G and M).