```
class Solution(object):
def combine(self, n, k):
res, stack=[], [([i for i in xrange(1,n+1)], k, [])]
while stack:
lst, k, temp=stack.pop()
if k<=len(lst):
if not k: res+=temp,
for i in xrange(len(lst)): stack+=(lst[i+1:],k-1,temp+[lst[i]]),
return res
```