CodeLab Academy 📞 9936 6696
← List Python · Level 10: Algorithms Code · 100 points ← #946 #948 →

#947. All combinations

You get n and k. Print all ways to choose k elements from 1..n, in lexicographic order, one per line. ### Input One line: n k (1 ≤ k ≤ n ≤ 6). ### Output Lines.

Examples

Input
6 3
Output
1 2 3
1 2 4
1 2 5
1 2 6
1 3 4
1 3 5
1 3 6
1 4 5
1 4 6
1 5 6
2 3 4
2 3 5
2 3 6
2 4 5
2 4 6
2 5 6
3 4 5
3 4 6
3 5 6
4 5 6
Input
4 4
Output
1 2 3 4

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!