Read the problem statement. If you are impatient please make yourself know that this is a basic version of most of the chess engines before machine learning took the throne -_-.
You can change the board size by modifying these variables 'M' as mentioned in the program. Note that M value is not limited by standard board size 8X8, although higher value of M will consume huge time.
For more information regarding input format, constraints etc. please read the problem statement.
Feel free to contact regarding sugesstions, implementation doubts etc. in the written program.