import numpy as	np



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

x = []

for i in range(n):

    x.append(list(map(int, input().split())))



x = np.array(x)



count =	0

for i in range(n):

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

        dist = np.linalg.norm(x[i] - x[j])

        if dist == int(dist):

            count += 1



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

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





def dist(a, b):

    sm = 0

    for ea, eb in zip(a, b):

        sm += (ea - eb) ** 2



    return sm ** 0.5





ans = 0

for i in range(n):

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

        dst = dist(x[i], x[j])

        for k in range(int(16000 ** 0.5) + 1):

            if k == dst:

                ans += 1

                break



print(ans)

import numpy as np

n, d = list(map(int, input().split()))
x = []
for i in range(n):
    x.append(list(map(int, input().split())))
x = np.array(x)
count = 0
for i in range(n):
    for j in range(i + 1, n):
        dist = np.linalg.norm(x[i] - x[j])
        if dist == int(dist):
            count += 1
print(count)

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


def dist(a, b):
    sm = 0
    for ea, eb in zip(a, b):
        sm += (ea - eb) ** 2
    return sm**0.5


ans = 0
for i in range(n):
    for j in range(i + 1, n):
        dst = dist(x[i], x[j])
        for k in range(int(16000**0.5) + 1):
            if k == dst:
                ans += 1
                break
print(ans)

-import numpy as np +n, d = list(map(int, input().split())) +x = [list(map(int, input().split())) for _ in range(n)] -n, d = list(map(int, input().split())) -x = [] -for i in range(n): -    x.append(list(map(int, input().split()))) -x = np.array(x) -count = 0 + +def dist(a, b): +    sm = 0 +    for ea, eb in zip(a, b): +        sm += (ea - eb) ** 2 +    return sm**0.5 + + +ans = 0 -        dist = np.linalg.norm(x[i] - x[j]) -        if dist == int(dist): -            count += 1 -print(count) +        dst = dist(x[i], x[j]) +        for k in range(int(16000**0.5) + 1): +            if k == dst: +                ans += 1 +                break +print(ans)