Magic machine (#529) - Azerbaijan Computing Olympiad