NOKIA brute force code

I was trying to solve the qstn i deduced recursive relation as in editorial but i can’t code please help me by giving pseudo code of brute force method

Brute force will take way longer than time limit. Try to induce all the possible wire lengths for different N (start with small N) and you may discover some nice properties