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
2012-12-29 13:09:02 Avi [OneMoreTry]
is there any tricky case?
please do help
2012-08-24 19:07:37 DEVANSH PARASHAR
c++ not working
2012-08-15 18:16:28 AC Srinivas
isn't the 1st case answer 20? cds are unique right?
2012-08-01 22:29:30 StupidGuy
Difficult with c/c++, stuck with language manipulation.
Finally AC :)
My First Code in Python, Hell Yeah!

Last edit: 2012-08-02 00:01:53
2012-06-14 10:45:31 shivamrana
166B with python.... ;)
2012-06-12 12:00:30 diablo
i get a runtime error everytime i try to submit.. the code is in python.. what could be the reason.. im even using try.. except
2012-02-25 07:41:25 BlackBird
111 characters :D
2011-10-11 09:46:44 Shafaet
u can use python
2010-12-20 13:30:32 yyf
Source limit:512B!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.