Intel Corporation interview question

Solve an MXN game