main = interact $ unlines . map (show . lagrangeFST . read) . init . lines
 
lagrangeFST n = search 0 1 n
 where
  search i m x
   | i>4 || x<0 = 0
   | x==0 = 1
   | otherwise = sum [search (i+1) x' (x-x'^2) | x'<-[m..(floor (sqrt (fromIntegral x)))]]