import Data.List
??
main = interact $ unlines . map (show . comb_of_numseq . map read . words) . lines
??
comb_of_numseq [n,s]
  | s > 330 = 0
  | otherwise = length $ filter ((==s) . fst) $ candidate n s
??
candidate x s = perms (0,[]) (map (*) [1..x]) [0..9]
??where
????perms acc [] _ = [acc]
????perms (s',cs') (f:fs) cs = concat [perms (s'', (c':cs')) fs (delete c' cs) | c'<-cs, let s'' = s' + f c', s''<=s]