\problemname{Vin Diagrams}

Venn diagrams were invented by the great logician John Venn as a way of
categorizing elements belonging to different sets. Given two 
sets $A$ and $B$, two overlapping circles are drawn -- a circle
representing the elements of $A$, and another representing the elements of $B$.
The overlapping region of the circles represents element that
belong to both $A$ and $B$, i.e., the intersection of the two sets
$A \cap B$. A classic Venn
diagram might look like this:
\begin{center}
\scalebox{0.8}{\includegraphics{vin1}}\\
Figure H.1
\end{center}
One of John's biggest fans was his grandson, Vin Vaughn Venn. Vin was inspired by his
grandfather's diagrams, but Vin was a very creative individual. Simple overlapping
circles struck Vin as too boring of a way to visualize the sometimes messy intersections
of categories, so he set out to make his grandfather's diagrams more interesting. Just
like Venn diagrams, Vin diagrams are used as a way of categorizing elements belonging
to different sets $A$ and $B$, but the representation of each set is not required to
be a circle. In fact, each set can have any shape as long as there is single overlapping
section for elements in the intersection of $A$ and $B$.

In this problem, Vin diagrams will be laid out on a grid.
Each set representation is a loop of `{\tt X}' characters, with one `{\tt X}'
in each loop replaced by an `{\tt A}' or `{\tt B}' to identify the loop.
All empty positions (both
inside and outside of the loops) are represented by period (`.') characters,
and the set of positions inside a loop is contiguous.
Each loop character touches exactly two other loop characters either vertically
or horizontally. Loops do not self-intersect, and other than the allowed
horizontal/vertical paths and right angle connections, different parts of the
loop do not touch (see Figures H.2 and H.3 below).

\begin{center}
%\tt
%\begin{tabular}{|cccccc|} \hline
%A & X & X & X & X & \hspace*{0.5in} \\
%X & . & . & . & X & \\
%X & . & . & X & X & \\
%X & . & . & X & X & \\
%X & . & . & . & X & \\
%X & X & X & X & X & \\ \hline
%\multicolumn{6}{l}{\rm Figure H.2: Illegal loop}
%\end{tabular}
%\begin{tabular}{|cccccccc|} \hline
%X & X & B & X & X & . & . & \hspace*{0.5in} \\
%X & . & . & . & X & . & . &  \\
%X & . & . & . & X & X & X &  \\
%X & X & X & X & . & . & X &  \\
%. & . & . & X & X & X & X &  \\
%  &   &   &   &   &   &   &  \\ \hline
%\multicolumn{6}{l}{\rm Figure H.3: Illegal loop}
%\end{tabular}
\framebox[2in]{
\scalebox{1.5}{\includegraphics{vin2a}}
}
\framebox[2in]{
\scalebox{1.5}{\includegraphics{vin3a}}
\vspace*{0.1in}
}

\hspace*{0.15in} Figure H.2: Two legal loops \hspace*{0.3in} Figure H.3: Two illegal loops
\end{center}
Loops A and B intersect at exactly two points.  Loop intersection points always
follow the pattern shown in Figure H.4 (including the four `.' positions around
the intersection).  No loop makes a right angle turn at
an intersection point but always flows straight through the intersection, either
vertically or horizontally. An example of legally intersecting loops is shown
in Figure H.5.
\begin{center}
%\tt
%\begin{tabular}{|cccc|} \hline
%. & X & . & \\
%X & X & X & \\
%. & X & . & \\
%  &   &   & \\
%  &   &   & \\
%  &   &   & \\
%  &   &   & \\ \hline
%\multicolumn{4}{l}{\rm Figure H.4: Intersection points and surrounding positions}
%\end{tabular}
%\begin{tabular}{|cccccccc|} \hline
%A & X & X & X & X & . & . & \\
%X & . & . & . & X & . & . & \\
%X & . & X & X & X & X & X & \\
%X & . & X & . & X & . & X & \\
%X & X & X & X & X & . & X & \\ 
%. & . & X & . & . & . & X & \\ 
%. & . & X & X & X & X & B & \\ \hline
%\multicolumn{8}{l}{\rm Figure H.5: Legally intersecting loops}
%\end{tabular}
\framebox[2in]{
\scalebox{0.8}{\includegraphics{vin4}}
}
\hspace*{0.5in}
\framebox[2in]{
\scalebox{0.8}{\includegraphics{vin5}}
\vspace*{0.1in}
}

\hspace*{0.1in} Figure H.4: Intersection point and \hspace*{0.5in} Figure H.5: Legally intersecting loops

\vspace*{-0.05in} surrounding positions \hspace*{2.35in} \mbox{ }
\end{center}

\pagebreak

\section*{Input}
The input starts with two integers $r$ $c$ describing the number of rows and columns in the Vin diagram ($7 \leq r, c \leq 100$). The following $r$ rows each contain a string
of $c$ characters. All positions that are not part of loop $A$ or loop $B$ are
marked with a period (`.') character. 
The loop labels `A' and `B' are placed somewhere around the loops' perimeters
at non-intersection positions and are never on the same loop.

\section*{Output}
Display, in order, the area of the Vin diagram exclusive to set $A$, the area exclusive to set $B$, and the area of the intersection. Given the representation of Vin diagrams, the area of a section is defined as the number of periods (`.') it encloses.

