| t | import math | t | import math |
| N = int(input().strip()) | | N = int(input().strip()) |
| limit = int(math.isqrt(N)) | | limit = int(math.isqrt(N)) |
| solutions = [] | | solutions = [] |
| for x in range(limit, -1, -1): | | for x in range(limit, -1, -1): |
| rem1 = N - x * x | | rem1 = N - x * x |
| if rem1 < 0: | | if rem1 < 0: |
| continue | | continue |
| for y in range(x, -1, -1): | | for y in range(x, -1, -1): |
| rem2 = rem1 - y * y | | rem2 = rem1 - y * y |
| if rem2 < 0: | | if rem2 < 0: |
| continue | | continue |
| for z in range(y, -1, -1): | | for z in range(y, -1, -1): |
| rem3 = rem2 - z * z | | rem3 = rem2 - z * z |
| if rem3 < 0: | | if rem3 < 0: |
| continue | | continue |
| t = int(math.isqrt(rem3)) | | t = int(math.isqrt(rem3)) |
| if t * t == rem3 and t <= z: | | if t * t == rem3 and t <= z: |
| solutions.append((x, y, z, t)) | | solutions.append((x, y, z, t)) |
| solutions.sort() | | solutions.sort() |
| for quad in solutions: | | for quad in solutions: |
| print(*quad) | | print(*quad) |