This page is still under construction.

Parts of this page are still being built. What you see may change.

Increasing Subsequences

Time limit4sMemory limit128 MB

Summary
Count permutations of 1..N whose longest increasing subsequence has length exactly B, modulo 1,000,000,000.
Level

Hard8 of 10

Topics
Dynamic programming, Combinatorics, Math
Solved
No attempts yet

Problem

A sequence p(1),p(2),…,p(N)p(1), p(2), \ldots, p(N) made up of the numbers 1,2,…,N1, 2, \ldots, N is called a permutation if all of its elements are distinct.

A permutation pp is said to contain an increasing subsequence of length kk when there exist indices 1≤i1<i2<⋯<ik≤N1 \le i_1 < i_2 < \cdots < i_k \le N such that p(i1)<p(i2)<⋯<p(ik)p(i_1) < p(i_2) < \cdots < p(i_k).

When a permutation pp contains an increasing subsequence of length BB but does not contain one of length B+1B+1, the number BB is called the degree of increase of that permutation.

Given a number NN, write a program that counts the permutations whose degree of increase is exactly BB. Because this count can be very large, output its remainder modulo 1,000,000,0001{,}000{,}000{,}000.

Input

The input consists of a single line containing two integers NN and BB (1≤N≤401 \le N \le 40, 1≤B≤51 \le B \le 5), separated by one or more spaces.

Output

Output a single integer: the number of permutations whose degree of increase is exactly BB, taken modulo 1,000,000,0001{,}000{,}000{,}000.

Examples1

  1. Example 1

    Input
    3 2
    
    Expected output
    4