#!/usr/bin/python3

import sys
from math import sqrt

with open(sys.argv[1], 'r') as input_file:
    limit = int(input_file.read())

data = []

for a in range(1, limit + 1):
    for b in range(a + 1, limit + 1):
        c = round(sqrt(pow(a, 2) + pow(b, 2)))
        if pow(a, 2) + pow(b, 2) == pow(c, 2) and c <= limit:
            data.append((a, b, c))

user_data = []

with open(sys.argv[2], 'r') as output_file:
    raw_data = output_file.readlines()
    for line in raw_data:
        user_chunk = tuple(map(int, line.split()))
        user_data.append((min(user_chunk[0], user_chunk[1]), max(user_chunk[0], user_chunk[1]), user_chunk[2]))

if sorted(data) == sorted(user_data) and len(data) == len(user_data):
    exit(0)
else:
    print("{} is not equal {}\n".format(str(sorted(data)), str(sorted(user_data))), file=sys.stderr)
    exit(5)
