Solution (SPOILER)

Let's consider the case a = 0 and b = 0. Obviously, the answer will be n * n, because none of the knights will be able to move to any other cell of the table. Now let's assume that a != 0 or b != 0. By doing some casework, one can show that the answer for n will be the same as the answer for min(n, 10), so we can assume that n <= 10. Then, just find all possible night moves and get connected components of the corresponding graph. The answer will be the number of connected components.