place white and black knights on 2x2 chessboard

JavaScript
Input:
N = 2,M = 2
Output: 12 

Source

Also in JavaScript: