Magnetic field lines avoid passing through diamagnetic materials. Due to this reason, the bar of diamagnetic material aligns perpendicular to the magnetic field.
Magnetic field lines prefer passing through the paramagnetic materials. So, the bar of paramagnetic material aligns parallel to the magnetic field.