solve https://algospot.com/judge/problem/read/MMRECT1