# Braces in Tabular after some of the rows

I have the following code, my problem is that the braces 'A' should be the after row A1 and B1 and the second braces should be after D1 and E1. Hope someone can help?

\begin{tabular}{c@{}c}

\begin{tabular}{|c|c|c|c|c|c|c|c|@{}}\hline
&$A$&$B$&$C$&$D$&$E$&$F$\\\hline
$A1$&2&5&11&13&5&7\\\hline
$B1$&6&8&10&10&10&10\\\hline
$C1$&13&11&5&12&1&1\\\hline
$D1$&6&6&5&4&2&2\\\hline
$E1$&k&0&0&0&0&6\\\hline
$F1$&9&3&17&0&5&\\\hline
\multicolumn{1}{c}{} &
\multicolumn{2}{@{}c@{}}{$\underbrace{\hspace*{\dimexpr6\tabcolsep+2\arrayrulewidth}\hphantom{012}}_{\mathcal{B}}$} & \multicolumn{1}{c}{}&
\multicolumn{1}{@{}c@{}}{$\underbrace{\hspace*{2\tabcolsep}\hphantom{3}}_{\mathcal{B}}$}
\end{tabular}
&
$\begin{array}{l} \MyLBrace{3.5ex}{$\mathcal{A}$} \\ \\ \MyLBrace{3.5ex}{$\mathcal{A}$} \\ \end{array}$
\end{tabular}

-
Please tell us how \MyLBrace is defined. – Mico Mar 19 at 9:30

Here's a solution that uses just one array environment.
\documentclass{article}
$\begin{array}{|*{7}{c|}@{}c} \cline{1-7} &A&B&C&D&E&F\\ \cline{1-7} A1&2&5&11&13&5&7& \multirow{2}{*}{$\left.\rule[1.5ex]{0pt}{1.5ex}\right\}\mathcal{A}$}\\ \cline{1-7} B1&6&8&10&10&10&10\\ \cline{1-7} C1&13&11&5&12&1&1&\multirow{2}{*}{$\left.\rule[1.5ex]{0pt}{1.5ex}\right\}\mathcal{A}$}\\ \cline{1-7} D1&6&6&5&4&2&2\\ \cline{1-7} E1&k&0&0&0&0&6\\ \cline{1-7} F1&9&3&17&0&5&\\ \cline{1-7} \multicolumn{1}{c}{} & \multicolumn{2}{@{}c@{}}{\underbrace{\hspace*{\dimexpr4\tabcolsep+1\arrayrulewidth}\hphantom{123}}_{\mathcal{B}}} & \multicolumn{1}{c}{} & \multicolumn{1}{@{}c@{}}{\underbrace{\hspace*{2\tabcolsep}\hphantom{.}}_{\mathcal{B}}} \end{array}$