f=lambda n,k:n>1<k and f(n,k-1)+f(n-1,k)or'987654321\n'[~n:]
for (n, k) in (5, 1), (5, 2), (5, 3), (3, 3), (2, 4), (2, 3), (1, 4):
print (n, k)
print f(n, k)
Zj1sYW1iZGEgbixrOm4+MTxrIGFuZCBmKG4say0xKStmKG4tMSxrKW9yJzk4NzY1NDMyMVxuJ1t+bjpdCgpmb3IgKG4sIGspIGluICg1LCAxKSwgKDUsIDIpLCAoNSwgMyksICgzLCAzKSwgKDIsIDQpLCAoMiwgMyksICgxLCA0KToKCXByaW50IChuLCBrKQoJcHJpbnQgZihuLCBrKQ==
(5, 1)
54321
(5, 2)
54321
4321
321
21
1
(5, 3)
54321
4321
321
21
1
4321
321
21
1
321
21
1
21
1
1
(3, 3)
321
21
1
21
1
1
(2, 4)
21
1
1
1
(2, 3)
21
1
1
(1, 4)
1