Question here: https://www.codechef.com/practice/course/4-star-difficulty-problems/DIFF1900/problems/ICL1901?tab=statement
1st submission with just while True: https://www.codechef.com/viewsolution/1055683164
2nd submission running the same code just twice: https://www.codechef.com/viewsolution/1055683982
Why is it so that all combinations are exhausted in only 2 iterations?
Extra doubt:
Why and how does this solution work?: https://www.codechef.com/viewsolution/89676081