One molecule contains 2 N, you know this mass.
The nitrogen mass makes up 28% of a molecule, so you know the molar mass.
The rest, 72%, is made by 3 atoms of Y : deduce the molar mass of Y, hence the element.
Your teacher cheated with the 72% and 28%, but the molar masses are not integers.