Given a square table sized NxN (3 ≤ N ≤ 5,000; rows and columns are indexed from 1) with a robot on it. The robot has a mission of moving from cell (1, 1) to cell (N, N) using only the directions "right" or "down". You are requested to find the number of different ways for the robot using exactly K turns (we define a "turn" as a right move
followed immediately by a down move, or a down move followed immediately by a right move; 0 < K < 2N-2).

Input
There are several test cases (5,000 at most), each consisting of a single line containing two positive integers N, K.

The input is ended with N = K = 0.


Output
For each test case, output on a line an integer which is the result calculated. The number of ways may be very large, so compute the answer modulo 1,000,000,007.

Example

Input:
4 2
4 3
5 3
0 0

Output:
4
8
18

Explanation for the first sample test case: 4 ways are RRDDDR, RDDDRR, DRRRDD, DDRRRD ('R' or 'D' represents a right or down move respectively).
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Robot Movings

Problem Code : MOVES
---------------------------------------------------------------------------------------------------------------------------------------------
DESCRIPTION

Given a square table sized [N x N] (3 ≤ N ≤ 5,000; rows and columns are indexed from 1) with a robot on it. The robot has a mission of moving from cell (1, 1) to cell (N, N) using only the directions "right" or "down". You are requested to find the number of different ways for the robot using exactly K turns (we define a "turn" as a right move followed immediately by a down move, or a down move followed immediately by a right move; 0 < K < 2N-2).


INPUT

There are several test cases (5,000 at most), each consisting of a single line containing two positive integers N, K.

The input is ended with N = K = 0.


OUTPUT

For each test case, output on a line an integer which is the result calculated. The number of ways may be very large, so compute the answer modulo 1,000,000,007.

---------------------------------------------------------------------------------------------------------------------------------------------

OBSERVATIONS

1. Because we are restricted to only being able to move a unit to the right or a unit down, we can assume any paths we generate will not contain cycles.

2. A valid path from (1, 1) to (N, N) must have exactly N-1 right movements and N-1 down movements. 

3. A valid path from (1, 1) to (N, N) with K turns can be expressed as a sequence of K+1 alternating subsequences where each subsequence is either a sequence of repeated right moves or a sequence of repeating down moves. 

4. Assume you have a solution P that starts with a sequence of right moves. You can construct a new solution from this solution defined as the compliment of P (~P) where all right moves are swapped with down moves and all down moves are swapped with right moves. 

Example

N = 7 {[7 x 7] matrix of cells}

K = 3 Turns

P is a valid path from (1, 1) to (N, N) that starts with a right turn.

P = [R, R, R, D, R, R, R, D, D, D, D, D]
  = [R  R  R | D | R  R  R | D  D  D  D  D]
  = [{R, R, R}, {D}, {R, R, R}, {D, D, D, D, D}]

~P = [{D, D, D}, {R}, {D, D, D}, {R, R, R, R, R}]

5. Moving from one subsequence to the next corresponds to a turn.

SOLUTION PROPOSALS

=============================================================================================================================================

1. Brute force over all paths

Input: n, k

Generate all 2^(2(n-1)) possible paths of size 2(n-1) from cell (1, 1) to cell (n, n) and for each path (as they are generated) keep count how many use k turns modulo 1,000,000,007.

Space Complexity : O(1)

Time Complexity : 2^(2(n-1)) = 4^(n-1) = (4^n)/4 = O(4^n)

Evaluation : Not feasible for problem constraints

=============================================================================================================================================

2. Reduction to counting integer partitions

Input: n, k

Define X as the space of all valid paths with k turns

Define P as the space of all valid paths with k turns beginning with a subsequence of right moves.

Define ~P as the space of all valid paths with k turns beginning with a subsequence of down moves.

|X| = |P| + |~P| = 2|P|

Reduce each subsequence in a path p in P to its integral size to get a sequence of positive integers

p => [3, 1, 3, 5]

The sum of the elements in this reduced path must equal 2*(n-1). This is because the number of moves must sum to 2*(n-1).

Valid paths will always reduce to integer sequences who's integral elements sum to 2*(n-1).
However not all integer sequences that sum up to 2*(n-1) are going to be mappable to a path p in P.

The size of p in P (call it m) will always equal k+1

{e[1] , e[2] , ... , e[i] , e[i+1] , ... , e[m]}

for 1 <= i <= m

let r[i] be an element in p representing an integer number of right moves

let d[i] be an element in p representing an integer number of down moves


We know the integers alternate in terms of number of right moves and number of down moves we can look at it like...

If m is even then we get a sequence that looks like

{r[1] , d[1] , ... , r[i] , d[i] , ... , r[m/2] , d[m/2]}

where there are an equal number of right and down integer subsequence counts

if m is odd we get a sequence that looks like

{r[1] , d[1] , ... , d[(m/2)], r[(m+1)/2]}

where there is one more subsequence of right moves than there are subsequences of down moves


if m is even then we can setup the following equations

1. r[1] + ... + r[i] + ... + r[(m/2)] = n-1

2. d[1] + ... + d[i] + ... + d[(m/2)] = n-1

if m is odd then we can setup the following equations

1. r[1] + ... + r[i] + ... + r[(m+1)/2]  = n-1

2. d[1] + ... + d[i] + ... + d[(m/2)]    = n-1


Calculating |P| reduces to counting the product of the number of possible positive integral solutions for equation 1 and the number of positive integral solutions for equation 2 in each case respectively

Equation 1 

Case 1 : m is even (i.e k is odd)

r[i] >= 1
y[i] = r[i]-1

==> (y[1] + 1) + ... + (y[(m/2)] + 1) = n-1

==> y[1] + ... + y[(m/2)] = (n-1) - (m/2)

= C(([(n-1) - (m/2)] + [(m/2)-1]),  [(m/2)-1])

= C((n-2), ((k+1)/2) - 1)

= C((n-2), (k-1)/2)


Case 2 : m is odd (i.e k is even)

r[i] >= 1
y[i] = r[i]-1

==> (y[1] + 1) + ... + (y[((m+1)/2)] + 1) = n-1

==> y[1] + ... + y[((m+1)/2)] = (n-1) - ((m+1)/2)

= C(([(n-1) - ((m+1)/2)] + [((m+1)/2)-1]), [((m+1)/2)-1])

= C((n-2), ((k+2)/2)-1)

= C((n-2), (k/2))


Because of the way integer division they realy both boil down to 

C((n-2), (k/2))

Basically if m is even (which means k is odd) then k/2 and (k-1)/2 evaluate to the same thing so it really reduces to one case


Equation 2

d[i] >= 1
y[i] = d[i]-1
y[i]+1 = d[i]

==> (y[1] + 1) + ... + (y[(m/2)] + 1) = n-1

==> y[1] + ... + y[(m/2)] = (n-1) - (m/2)

= C(([(n-1) - (m/2)] + [(m/2)-1]),  [(m/2)-1])

= C((n-2), ((k+1)/2) - 1)

= C((n-2), (k-1)/2)

Therefore...

|P| = |~P| = C((n-2), k/2) * C((n-2), (k-1)/2)

and |X| = 2*|P|

and finally...

You can calculate large numbers for the choose (binomial coefficent) method using the following recurrence defined as Pascal's rule
and a little bit of magic from the dynamic programming paradigm

C(X, Y) = C(X-1, Y-1) + C(X-1, Y)


A faster way to calculate this is to exploit the following property

x * x^(M-2) = 1 (mod M) if M is prime.

So x^(M-2) is the multiplicative inverse of x

Since 1000000007 is M and this number is prime

=============================================================================================================================================

"""
import sys

# Global Variables

M       = 5001
MOD     = 1000000007

factorial = [1]*M



# Helper Methods

def precompute_factorial_cache():
    for i in xrange(1, M):
        factorial[i] = (factorial[i-1] * i) % MOD


# INCORRECT WAY TO COMPUTE THIS
def choose(n, k):
    numerator = factorial[n]
    denominator = (factorial[k] * factorial[n-k]) % MOD
    return numerator * pow(denominator, MOD-2, MOD) 
    

def no_more_testcases(n, k):
    return not n and not k


def next_testcase():
    testcase = sys.stdin.readline().split()
    return int(testcase[0]), int(testcase[1])



# Begin main script

precompute_factorial_cache()

done = False

while not done:
    
    n, k = next_testcase()
    
    if no_more_testcases(n, k):
        done = True

    else:
        print (2*((choose(n-2, k/2) * choose(n-2, (k-1)/2)) % MOD)) % MOD