A. Ideal Generator Codeforces Round 1016 Div. 3 Math