The correct option is D 2- South, 4- North
Since the leftmost end of the magnet X is marked as the north pole, its right end (2) will surely be the south pole. This is because every magnet consists of two poles, namely the north and the south pole.
Also it is given in the question that the two bar magnets repel each other. We know that the same poles repel each other. Here, the two bar magnets are repelled through poles 2 and 3. This means that poles 2 and 3 are the same.
We have already figured out that end 2 is the south pole. So, as end 3 is repealed by end 2, end 3 will also be the south pole.
Similarly, since end 3 is the south pole, end 4 will surely be the north pole.
Hence, poles 2 and 4 are south and north poles respectively.