A context-free grammar is in Chomsky Normal Form if every rule is of the form
\[
\begin{array}{l}
A \longrightarrow B C \\
A \longrightarrow a
\end{array}
\]
where $a$ is a terminal, $A, B$ and $C$ are variables except $B$ and $C$ cannot be start variables. We only permit rule $S \longrightarrow \varepsilon$ if $S$ is a start variable.
Given the following grammar, convert it to Chomsky Normal Form.
\[
\begin{array}{l}
S \longrightarrow A S B \mid a B \\
A \longrightarrow B \mid S \\
B \longrightarrow b \mid \varepsilon
\end{array}
\]