What happens when two substances with different temperatures come into contact?

Thermal energy is transferred from the warmer substance to the cooler substance.
Thermal energy is transferred from the cooler substance to the warmer substance.
Potential energy is transferred from the warmer substance to the cooler substance.
Both substances gain thermal energy

The first statement is correct. When two substances with different temperatures come into contact, thermal energy is transferred from the warmer substance to the cooler substance until they reach thermal equilibrium. This process is known as heat transfer.