If Japan beat Mexico or draw then Japan
If Mexico beat Japan then Mexico, unless France beat South Africa by 5 goals more than Mexico beat Japan by (eg mex 1 - Jap 0 & Fra 6 - RSA 0)
If Japan beat or draw vs France we play them, so they are most likely.
If France win then Mexico beats South Africa as expected it will be down to gial diff between Mexico/France/Japan which means it would likely be Mexico unless France smashed Japan.