How to solve problem F — KTU programming camp (day 5)
Link to problem: 100741F - Matrix
Codeforces Educational Round 167 Solution Discussion (with Shayan)