5×5
for simplicity, then you have 25 unknowns. In the first case, there are 10 equations, and one of them cancels out, so that only gives you 9 constraints. In the third case, there are 40 pairs, but 16 of them cancel out, so that only gives you 24 constraints. In the second case, you can tile the grid with dominoes leaving 1 space; you know the sum of the 12 dominoes and the grid sum so that gives you its value, from which you can work out the rest of the grid.