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)

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





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(dst ** 0.5) + 1):

            if k ** 2 == dst:

                ans += 1

                break



print(ans)

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)

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


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(dst**0.5) + 1):
            if k**2 == dst:
                ans += 1
                break
print(ans)

-    return sm**0.5 +    return sm -        for k in range(int(16000**0.5) + 1): -            if k == dst: +        for k in range(int(dst**0.5) + 1): +            if k**2 == dst: