import Data.List

main = interact $ unlines . map (show . comb_of_numseq . map read . words) . lines

comb_of_numseq [n,s]
 | s > sum (zipWith ($) (reverse cf) [9,8..0]) = 0
 | s < sum (zipWith ($) cf [n-1,n-2..0]) = 0
 | otherwise = sum $ map (perms s [0..9]) (permutations cf)
 where
  cf = map (*) [1..n]
  perms 0 _ [] = 1
  perms _ [] _ = 0
  perms _ _ [] = 0
  perms s' (c:cs) ffs@(f:fs) = perms (s' - f c) cs fs + perms s' cs ffs