https://www.inphynity.tech/2021/04/codeforces-problem-beautiful-matrix.html