import math

from itertools import combinations

N,D = list(map(int,input().split()))

X = [list(map(float, input().split())) for i in range(N)]

counter = 0

for x0,x1 in combinations(X, 2):

    if math.sqrt(sum([(a-b)**2 for a, b in zip(x0,x1)])).is_integer():

        counter+=1

print(counter)

import math

from itertools import combinations

N,D = list(map(int,input().split()))

X = [list(map(float, input().split())) for i in range(N)]

counter = [(sum([(a-b)**2 for a, b in zip(x0,x1)])**0.5).is_integer() for x0,x1 in combinations(X, 2)]

print((sum(counter)))

import math
from itertools import combinations

N, D = list(map(int, input().split()))
X = [list(map(float, input().split())) for i in range(N)]
counter = 0
for x0, x1 in combinations(X, 2):
    if math.sqrt(sum([(a - b) ** 2 for a, b in zip(x0, x1)])).is_integer():
        counter += 1
print(counter)

import math
from itertools import combinations

N, D = list(map(int, input().split()))
X = [list(map(float, input().split())) for i in range(N)]
counter = [
    (sum([(a - b) ** 2 for a, b in zip(x0, x1)]) ** 0.5).is_integer()
    for x0, x1 in combinations(X, 2)
]
print((sum(counter)))

-counter = 0 -for x0, x1 in combinations(X, 2): -    if math.sqrt(sum([(a - b) ** 2 for a, b in zip(x0, x1)])).is_integer(): -        counter += 1 -print(counter) +counter = [ +    (sum([(a - b) ** 2 for a, b in zip(x0, x1)]) ** 0.5).is_integer() +    for x0, x1 in combinations(X, 2) +] +print((sum(counter)))