Using the right-hand thumb rule at the leftmost end of the solenoid, we see that our fingers would curl inward, thus showing that the magnetic field lines run from the left end to the right end, and we know the magnetic field lines run from the south to the north pole inside a bar magnet. So, the left end of the coil behaves as the south pole, while the right one behaves as the north pole.