Problem:
Score : 600 points

Problem Statement

Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|.

Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.

Constraints

All values in input are integers.

1 \leq n \leq 50

0 \leq k \leq n^2

Input

Input is given from Standard Input in the following format:

n k

Output

Print the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.

Sample Input 1

3 2

Sample Output 1

2

There are six permutations of {1,\ 2,\ 3}. Among them, two have oddness of 2: {2,\ 1,\ 3} and {1,\ 3,\ 2}.

Sample Input 2

39 14

Sample Output 2

74764168

Solution in Python (3.4.3) (judge verdict: Time Limit Exceeded)

# -*- coding:utf-8 -*-
# /usr/bin/python3

from collections import defaultdict

def main():
  n, score = map(int, input().strip().split(' '))
  dp = defaultdict(int)
  dp[(0,0,0)] = 1
  for i in range(n):
    for j in range(0, i+1):
      for k in range(0, score+1):
        dp[(i, j, k)] %= (10**9+7)
        dp[(i+1, j+1, k+(j+1))] += dp[(i, j, k)]
        dp[(i+1, j, k+j)] += dp[(i, j ,k)] * (j*2 + 1)
        if j-1 >= 0:
          dp[(i+1, j-1, k+(j-1))] += dp[(i, j, k)] * (j**2)
  if score % 2 == 1:
    print(0)
  else:
    print(dp[(n, 0, score//2)] % (10**9+7))

  pass

if __name__=='__main__':
  main()