LogiQuest

212. Combinations of K

MediumBacktracking

Print all combinations of k numbers chosen from 1..n in lexicographic order.

Input format

A single line: n k

Output format

C(n, k) lines.

Example 1

Input

4 2

Output

1 2
1 3
1 4
2 3
2 4
3 4

Example 2

Input

1 1

Output

1

Constraints

1 ≤ k ≤ n ≤ 12

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…