import sys

def f0070(A,n,s):

  if n==1:return s in A

  A=sorted(A)

  b1=0

  b2=0

  c=0

  j=1

  for e,f in zip(A[:n][::-1],A[-n:]):

    b1+=j*e

    b2+=j*f

    j+=1

  if b1<=s<=b2:

    for i in range(len(A)):

      c+=f0070(A[:i]+A[i+1:],n-1,s-A[i]*n)

  return c



for a in sys.stdin:

  n,s=list(map(int,a.split()))

  print(f0070(list(range(10)),n,s))
import sys

K=1024

N=331

R=list(range(K))

B=[1,2,4,8,16,32,64,128,256,512]

C=[0]*K

D=[[0 for i in range(N)]for j in R]



def init():

  global C,D

  for i in R:

    s=format(i,'b')

    n=s.count('1')

    C[i]=n

    if n==1:D[i][B.index(i)]=1

    else:

      for j in range(len(s)):

        if s[-j-1]=='1':

          dp=n*j

          i2=i-B[j]

          for k in range(N-dp):

            D[i][k+dp]+=D[i2][k]

  return

   

init()

for a in sys.stdin:

  n,s=list(map(int,a.split()))

  x=0

  if s<N:x=sum([D[i][s] for i in R if C[i]==n])

  print(x)
import sys


def f0070(A, n, s):
    if n == 1:
        return s in A
    A = sorted(A)
    b1 = 0
    b2 = 0
    c = 0
    j = 1
    for e, f in zip(A[:n][::-1], A[-n:]):
        b1 += j * e
        b2 += j * f
        j += 1
    if b1 <= s <= b2:
        for i in range(len(A)):
            c += f0070(A[:i] + A[i + 1 :], n - 1, s - A[i] * n)
    return c


for a in sys.stdin:
    n, s = list(map(int, a.split()))
    print(f0070(list(range(10)), n, s))

import sys

K = 1024
N = 331
R = list(range(K))
B = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
C = [0] * K
D = [[0 for i in range(N)] for j in R]


def init():
    global C, D
    for i in R:
        s = format(i, "b")
        n = s.count("1")
        C[i] = n
        if n == 1:
            D[i][B.index(i)] = 1
        else:
            for j in range(len(s)):
                if s[-j - 1] == "1":
                    dp = n * j
                    i2 = i - B[j]
                    for k in range(N - dp):
                        D[i][k + dp] += D[i2][k]
    return


init()
for a in sys.stdin:
    n, s = list(map(int, a.split()))
    x = 0
    if s < N:
        x = sum([D[i][s] for i in R if C[i] == n])
    print(x)

- -def f0070(A, n, s): -    if n == 1: -        return s in A -    A = sorted(A) -    b1 = 0 -    b2 = 0 -    c = 0 -    j = 1 -    for e, f in zip(A[:n][::-1], A[-n:]): -        b1 += j * e -        b2 += j * f -        j += 1 -    if b1 <= s <= b2: -        for i in range(len(A)): -            c += f0070(A[:i] + A[i + 1 :], n - 1, s - A[i] * n) -    return c +K = 1024 +N = 331 +R = list(range(K)) +B = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512] +C = [0] * K +D = [[0 for i in range(N)] for j in R] +def init(): +    global C, D +    for i in R: +        s = format(i, "b") +        n = s.count("1") +        C[i] = n +        if n == 1: +            D[i][B.index(i)] = 1 +        else: +            for j in range(len(s)): +                if s[-j - 1] == "1": +                    dp = n * j +                    i2 = i - B[j] +                    for k in range(N - dp): +                        D[i][k + dp] += D[i2][k] +    return + + +init() -    print(f0070(list(range(10)), n, s)) +    x = 0 +    if s < N: +        x = sum([D[i][s] for i in R if C[i] == n]) +    print(x)