# Arup Guha
# 6/15/2026
# Code for COT 3100 Homework #3 Question #9

import math

maxM = int(input("Enter max bound for m.\n"))

# Store triples here.
triples = []

for m in range(2, maxM+1):
    for n in range(1, m):

        # Not primitive.
        if math.gcd(m, n) != 1 or (m%2==1 and n%2==1):
            continue

        # Make the primitive triplet.
        c = m**2 + n**2
        a = m**2 - n**2
        b = 2*m*n

        # Add to list of triples
        triples.append([c, min(a,b), max(a,b)])

# Sort it!
triples.sort()

# Print in order. I reorder terms to be smaller leg, longer leg, hypotenuse
for x in triples:
    print(x[1],x[2],x[0])

'''
For m = 100, there are 2040 triples that get printed!
'''
