module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map (map int . words) . tail . lines
printer = unlines . (:[]) . show 

solver :: [[Int]] -> Int
solver (x:[]) = 0
solver (x:xs) = result + solver xs
  where
    result = length [ s |
      y<-xs ,
      let z= zipWith (-) x y ,
      let s= sum(zipWith (*) z z) ,
      (floor $ (sqrt $ fromIntegral s + 1e-8))^2 == s ]

  

