Rating:

TL;DR:

Reverse the first two for loops. The last one does not matter.

Original writeup (https://nischay.me/2020/04/28/Houseplant.html).