For a general $2$ by $2$ square, the column headings could be $x$ and $(x + 1)$, and the row headings could be $y$ and $(y + 1)$.

For a general $3$ by $3$ square, the column headings could be $x$, $(x + 1)$ and $(x + 2)$, and the row headings could be $y$, $(y + 1)$ and $(y + 2)$.

If you are struggling with the algebra take a look at Partitioning revisited.