Notation: $\text{HCF}$ is denoted below as $\text{gcd}$.
Assume you have two fractions $\frac{a}{b},\frac{c}{d}$ reduced to lowest
terms. Let
$$\begin{eqnarray*}
a &=&\underset{i}{\prod } p_{i}^{e_{i}(a)},\qquad b=\underset{i}{\prod } p_{i}^{e_{i}(b)}, \\
c &=&\underset{i}{\prod } p_{i}^{e_{i}(c)},\qquad d=\underset{i}{\prod } p_{i}^{e_{i}(d)}.
\end{eqnarray*}$$
be the prime factorizations of the integers $a,b,c$ and $d$. Then
$$\frac{\underset{i}{\prod }\ p_{i}^{\max \left( e_{i}(a),e_{i}(c)\right) }}{%
\prod_{i}\ p_{i}^{\min \left( e_{i}(b),e_{i}(d)\right) }}$$
is a fraction which is a common multiple of $\frac{a}{b},\frac{c}{d}$. It is
the least one because by the properties of the $\text{lcm}$ and $\gcd $ of
two integers, $\prod_{i}\ p_{i}^{\max \left( e_{i}(a),e_{i}(c)\right) }$ is the
least common multiple of the numerators and $\prod_{i}\ p_{i}^{\min \left(
e_{i}(b),e_{i}(d)\right) }$ is the greatest common divisor of the
denominators. Hence
$$\begin{eqnarray*}
\text{lcm}\left( \frac{a}{b},\frac{c}{d}\right) &=&\text{lcm}\left( \frac{{\prod_{i}\ p_{i}^{e_{i}(a)}}}{\prod_{i}\ p_{i}^{e_{i}(b)}},\frac{%
\prod_{i}\ p_{i}^{e_{i}(c)}}{\prod_{i}\ p_{i}^{e_{i}(d)}}\right)=\frac{\prod_{i}\ p_{i}^{\max \left( e_{i}(a),e_{i}(c)\right) }}{%
\prod_{i}\ p_{i}^{\min \left( e_{i}(b),e_{i}(d)\right) }}=\frac{\text{lcm}(a,c)}{\gcd (b,d)}.\quad(1)
\end{eqnarray*}$$
Similarly
$$\begin{eqnarray*}
\gcd \left( \frac{a}{b},\frac{c}{d}\right) =\gcd \left( \frac{{\prod_{i}\ p_{i}^{e_{i}(a)}}}{\prod_{i}p_{i}^{e_{i}(b)}},\frac{%
\prod_{i\ }p_{i}^{e_{i}(c)}}{\prod_{i}p_{i}^{e_{i}(d)}}\right) =\frac{\prod_{i}\ p_{i}^{\min \left( e_{i}(a),e_{i}(c)\right) }}{%
\prod_{i}\ p_{i}^{\max \left( e_{i}(b),e_{i}(d)\right) }} =\frac{\gcd (a,c)}{\text{lcm}(b,d)}.\quad(2)
\end{eqnarray*}$$
The repeated application of these relations generalizes the result to any
finite number of fractions.
Best Answer
(1) $12$ has to be part of both numbers - since it is the GCD.
(2) In order to get the LCM as $168$ we got to distribute the remaining $14$ among these two numbers, being careful that the distribution has no common factors.
(3) The factors of $14$ are $1,2,7,14$. So we take the first number as $12.1$, $12.2$, $12.7$, $12.14$ and the second number as $12.14$,$12.7$,$12.2$ and $12.1$ respectively
(4) Given that we exclude the extremities, we have only one value up to symmetry.
Finally, we have $\color{blue}{(A,B) \in \{(24,84), (84,24)\}}$
Some Notes
This problem becomes a little interesting if the LCM given was say $336$. Now you have to be more careful in distributing the $28$. It cannot be split as $2$ and $2$, otherwise it will affect the GCD. So you have to take the $4$ factor completely.
lab bhattacharjee has of of course a more formal approach.