Plain TeX has a control sequence \bordermatrix to handle this sort of thing. Unfortunately it's a bit inflexible. It only allows parenthesised matrices, and it only allows labels above and to the left, not below or to the right of the matrix. The input
\[
\bordermatrix{&\overbrace{}^N&\overbrace{}^k\cr \llap{${\scriptstyle N}\{$}&A&B\cr \llap{${\scriptstyle k}\{$}&C&D\cr}
\]
yields

.
Note the use of \llap to justify the braces to the left of the matrix. Without this, the labels would be left justified, giving a ragged appearance.