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

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

ans = 0

def k(a,b):

    dist = 0

    for i in range(d):

        dist +=(a[i]-b[i])**2

    dist = dist**(1/2)

    while dist > 0:

        dist -= 1

        if dist == 0:

            return True

    return False

for i in range(n):

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

        if k(x[i],x[j]):

            ans += 1



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

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



def ok(x,y):



    z = 0

    for i in range(d):

        z += (x[i]-y[i])**2

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

        return True

    else:

        return False



ans = 0

for i in range(n):

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

        if ok(data[i],data[j]):

            ans += 1



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


def k(a, b):
    dist = 0
    for i in range(d):
        dist += (a[i] - b[i]) ** 2
    dist = dist ** (1 / 2)
    while dist > 0:
        dist -= 1
        if dist == 0:
            return True
    return False


for i in range(n):
    for j in range(i + 1, n):
        if k(x[i], x[j]):
            ans += 1
print(ans)

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


def ok(x, y):
    z = 0
    for i in range(d):
        z += (x[i] - y[i]) ** 2
    if z ** (0.5) == int(z ** (0.5)):
        return True
    else:
        return False


ans = 0
for i in range(n):
    for j in range(i + 1, n):
        if ok(data[i], data[j]):
            ans += 1
print(ans)

-x = [list(map(int, input().split())) for i in range(n)] -ans = 0 +data = [list(map(int, input().split())) for i in range(n)] -def k(a, b): -    dist = 0 +def ok(x, y): +    z = 0 -        dist += (a[i] - b[i]) ** 2 -    dist = dist ** (1 / 2) -    while dist > 0: -        dist -= 1 -        if dist == 0: -            return True -    return False +        z += (x[i] - y[i]) ** 2 +    if z ** (0.5) == int(z ** (0.5)): +        return True +    else: +        return False +ans = 0 -        if k(x[i], x[j]): +        if ok(data[i], data[j]):