
# pyttrip1 
# Fig. 8.1. Prints all triples with z <= max. 
#input: 100

import math

from egcd import gcd

max = int(input("max=? "))
z = 1
while z <= max:
  z += 2
  n = z*z
  x = math.trunc(math.sqrt(n/2))
  y = x
  while x*x <= n:
    while x*x + y*y > n:
      y -= 1
    if x*x + y*y < n:
      x += 1
    else: 
      if gcd(x,y) == 1:
        print(f"{y:4} {x:4} {z:5}")
      x += 1
      y -= 1
