Help in MATBEAUT

Can someone tell me how to solve MATBEAUT problem in yesterday’s Cook-Off contest? The editorial for this problem hasn’t been released yet :frowning: