Imagine I have a solenoid connected to a power supply. Solenoid produces an electromagnetic field. Now I take a permanent magnet and place it inside the solenoid. How will the magnet align itself (assuming there is no gravity) inside the solenoid and will it rotate itself around the central axis "aligning" itself?
From these two cases cases, which one is correct behaviour and where would the "north" pole point (up, down, left or right):
P.S. What if the magnet is shaped differently, for example like a horseshoe, will it change its behaviour?