#!/usr/bin/env python3 import sys import math def lcm(a, b): return abs(a * b) // math.gcd(a, b) lines = list(sys.stdin.readlines()) for line in lines: assert line.endswith("\n"), f'Expected newline terminated string, got :"{line}"' k = int(lines[0]) assert len(lines) == k + 1, f"Expected {k + 1} lines, got {len(lines)}." assert 0 < k < 100, f"Expected 0 < {k} < 100" pairs = [tuple(map(int, lines[i + 1].split(" "))) for i in range(k)] for y, c1, c2 in pairs: assert 1800 <= y <= 2021, f"Expected 1800 <= y={y} <= 2021" assert 1 <= c1 <= 99, f"Expected 1 <= c1={c1} <= 99" assert 1 <= c2 <= 99, f"Expected 1 <= c2={c2} <= 99" # Just checking that they don't reappear before the competition reappears = [y + lcm(c1, c2) for (y, c1, c2) in pairs] for idx, e in enumerate(reappears): assert e > 2021, f"{idx} : {e} for {reappears[idx]} <= 2021(!)" sys.exit(42)