(c) Both AB and CD are magnets.
Like poles of a magnet repel each other whereas unlike poles attract each other. In the first figure when AB is aligned with CD, attraction occurs. It means that the two poles are opposite. In the second figure, when AB is aligned with DC, repulsion occurs. It means that the two poles are the same.