Complete Tree Labeling
A complete k-ary tree is a k-ary tree in which all leaves have same depth and all internal nodes have degree k. This k is also known as the branching factor of a tree. It is very easy to determine the number of nodes of such a tree.
Given the depth and branching factor of such a tree, you will have to determine in how many different ways you can number the nodes of the tree so that the label of each node is less that that of its descendants. You should assume that for numbering a tree with N nodes you have the (1, 2, 3, N-1, N) labels available.
Input
The input file will contain several lines of input. Each line will contain two integers k and d. Here k is the branching factor of the complete k-ary tree and d is the depth of the complete k-ary tree (k>0, d>0, k*d<=21).
Output
For each line of input, produce one line of output containing a round number, which is the number of ways the k-ary tree can be labeled, maintaining the constraints described above.