Magnetic interactions in the layer compounds MPX3 (M = Mn, Fe, Ni; X = S, Se)