import java.util.*;


public class Solution {
    
    ArrayList<ArrayList<Integer>> res = new ArrayList<>();
    
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param n int整型 
     * @param k int整型 
     * @return int整型ArrayList<ArrayList<>>
     */
    public ArrayList<ArrayList<Integer>> combine (int n, int k) {
        // write code here
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = i + 1;
        }
        ArrayList<Integer> currentArr = new ArrayList<>();
        process(currentArr, nums, 0, k);
        return res;
    }
    
    public void process(ArrayList<Integer> currentArr, int[] nums, int index, int k) {
        if (currentArr.size() == k) {
            ArrayList<Integer> copyArr = new ArrayList<>();
            copyArr.addAll(currentArr);
            res.add(copyArr);
            return;
        }
        if (index >= nums.length) {
            return;
        }
        process(currentArr, nums, index + 1, k);
        ArrayList<Integer> tmpArr = new ArrayList<>();
        tmpArr.addAll(currentArr);
        tmpArr.add(nums[index]);
        process(tmpArr, nums, index + 1, k);
    }
}