West is in 5S after North overcalled 2D and N/S competed to 5D. (5D doubled would have been a good sacrifice against an easy 4S.)
The defence lead diamonds, and Declarer ruffs the second diamond and draws trumps in 3 rounds.
Declarer cannot avoid a club loser, and cannot avoid a heart loser if South has the HK. But North is likely to hold the HK since he overcalled and has only shown 8 points. So Declarer plays assuming North has the HK. Even if that is correct, Declarer will be lucky to avoid a heart loser.
To give himself the best chance, Declarer plays CA, CK, and another club. If clubs are 3-3, the defence will have to start leading hearts, which may be beneficial for Declarer. North recognises the danger of being thrown in with the 3rd round of clubs, and drops the CQ on the second round. (If Declarer held the CJ, he would probably have played the suit in a different way).
South wins the 3rd round and has to lead a heart, or give a ruff and discard. He chooses the H5.
North’s play in dropping the CQ reinforces Declarer's assumption about the HK. Having shown at least 5 diamonds and 3 in both spades and clubs North can have at most 2 hearts. He could hold HK10 (in which case Declarer would need to play an honour) but is more likely to hold HKx or HK singleton. So Declarer plays low from hand, and makes his contract.