UJ - Uncle Jack

Dear Uncle Jack is willing to give away some of his collectable CDs to his nephews. Among the titles you can find very rare albums of Hard Rock, Classical Music, Reggae and much more; each title is considered to be unique. Last week he was listening to one of his favorite songs, Nobody’s fool, and realized that it would be prudent to be aware of the many ways he can give away the CDs among some of his nephews.

So far he has not made up his mind about the total amount of CDs and the number of nephews. Indeed, a given nephew may receive no CDs at all.

Please help dear Uncle Jack, given the total number of CDs and the number of nephews, to calculate the number of different ways to distribute the CDs among the nephews.

Input

The input consists of several test cases. Each test case is given in a single line of the input by, space separated, integers N (1 <= N <= 1000) and D (0 <= D <= 2500), corresponding to the number of nephews and the number of CDs respectively. The end of the test cases is indicated with N = D = 0.

Output

The output consists of several lines, one per test case, following the order given by the input. Each line has the number of all possible ways to distribute D CDs among N nephews.

Example

Input:
1 20
3 10
0 0

Output:
1
59049

Added by:Camilo Andrés Varela León
Date:2006-10-25
Time limit:1s
Source limit:512B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:XX Colombian National Programming ACM 2006

hide comments
2014-04-17 14:05:44 fanatique
..ac...similar to small factorials..
2013-12-24 08:15:24 Test
yeah !! it should be 66
2013-12-24 07:30:43 RG
i think the answer for second case would be 66 ??
2013-08-17 13:56:28 Hitman
for d=0 ans will be 1. It caused me 3 WA
2013-05-01 13:18:41 ওয়াসী (Wasi)
at last my python 3.2.3 code runs with 0.19 run time... :D
nice problem!
2013-05-01 00:05:12 Eduardo Nunes
indeed, easy one with python :-D
2013-04-17 17:01:18 :-)
very easy problem
77B python solution
2013-03-08 08:58:37 [Lakshman]
<snip>
here my java code is working fine for all values but wa
got AC using python same thing giving wrong answer in JAVA..

Last edit: 2023-09-22 20:35:18
2013-03-07 19:35:40 me codesta a.k.a w@s!m
My First Code in Python :D
2013-01-12 14:48:12 arijit pande
AC in Python :D
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.