Under construction

Still being built. Things may change

Tree Inside a Tree

Time limit1sMemory limit1024 MB

Summary
Count the ways to delete vertices and edges from perfect binary tree T_N so the remainder is isomorphic to perfect binary tree T_K, modulo 1000000007.
Level

Medium6 of 10

Topics
Dynamic programming, Tree, Combinatorics
Solved
No attempts yet

Problem

A perfect binary tree of height tt, TtT_t, is an undirected graph with vertices numbered 1 to 2t+1−12^{t+1}-1. For every integer ii with 1≤i≤2t−11 \leq i \leq 2^t-1, there is an edge between vertex ii and vertex 2i2i, and an edge between vertex ii and vertex 2i+12i+1.

Two graphs GG and HH are isomorphic if there is a one-to-one function f:V(G)→V(H)f: V(G) \to V(H) such that for any two vertices uu and vv of GG, uu and vv are adjacent in GG if and only if f(u)f(u) and f(v)f(v) are adjacent in HH. Here V(G)V(G) and V(H)V(H) are the vertex sets of GG and HH.

Count the number of ways to remove zero or more vertices and edges from TNT_N so that the resulting graph is isomorphic to TKT_K.

Input

The first line contains two integers NN and KK, separated by a space. (1≤K≤N≤50001 \leq K \leq N \leq 5000)

Output

On the first line, print the answer modulo 10000000071000000007. 10000000071000000007 is a prime number.

Examples2

  1. Example 1

    Input
    2 1
    
    Expected output
    7
    
  2. Example 2

    Input
    3 2
    
    Expected output
    3