import numpy as np

n,d=list(map(int,input().split()))

x=[list(map(int,input().split())) for i in range(n)]

count=0

for i in range(n-1):

    for j in range(i+1,n):

        a=np.array(x[i])

        b=np.array(x[j])

        ab=sum(np.power((a-b),2))**0.5

        if ab%1==0:

            count+=1

print(count)
n,d=list(map(int,input().split()))

L=[list(map(int,input().split())) for i in range(n)]

ans=0

for i in range(n-1):

    for j in range(i+1,n):

        a=0

        for k in range(d):

            a+=(L[i][k]-L[j][k])**2

        if int(a**0.5)==a**0.5:

            ans+=1

print(ans)
import numpy as np

n, d = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(n)]
count = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        a = np.array(x[i])
        b = np.array(x[j])
        ab = sum(np.power((a - b), 2)) ** 0.5
        if ab % 1 == 0:
            count += 1
print(count)

n, d = list(map(int, input().split()))
L = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        a = 0
        for k in range(d):
            a += (L[i][k] - L[j][k]) ** 2
        if int(a**0.5) == a**0.5:
            ans += 1
print(ans)

-import numpy as np - -x = [list(map(int, input().split())) for i in range(n)] -count = 0 +L = [list(map(int, input().split())) for i in range(n)] +ans = 0 -        a = np.array(x[i]) -        b = np.array(x[j]) -        ab = sum(np.power((a - b), 2)) ** 0.5 -        if ab % 1 == 0: -            count += 1 -print(count) +        a = 0 +        for k in range(d): +            a += (L[i][k] - L[j][k]) ** 2 +        if int(a**0.5) == a**0.5: +            ans += 1 +print(ans)