; or (iii) required under paragraph (4). (3) Exceptions to Immediate Release At the initial appearance hearing, the judicial officer may temporarily detain the person until the pretrial release hearing only in accordance with the following: (A) Mandatory temporary detention pending a pretrial release hearing Except as provided in subparagraph (D), the judicial officer shall order temporary detention and shall hold a pretrial release hearing under subsection (f) when the person is charged with one of the following offenses: (i) Offenses involving a minor victim A violation of section 1591, or any felony that involves a minor victim. (ii) Certain terrorism offenses An offense listed in section 2332b(g)(5)(B) for which a maximum term of imprisonment of 10 years or more is prescribed. (iii) Other serious offenses An offense for which the maximum sentence is life imprisonment or death, other than an offense listed in subparagraph (B)(i) or (B)(ii) for which the maximum sentence is life imprisonment. (iv) Certain repeat offenses Any felony if the person has been convicted of two or more offenses described in paragraph (3)(A)(iii) or (3)(B)(iii) of this subsection, or two or more State or local offenses that would have been offenses described in paragraph (3)(A)(iii) or (3)(B)(iii) of this subsection if a circumstance giving rise to Federal jurisdiction had existed, or a combination of such offenses. (B) Discretionary temporary detention Except as provided in subparagraph (D), on a showing by the attorney for the Government of a likelihood of success on the merits at obtaining an order for detention at the pretrial release hearing, the judicial officer may order temporary detention and may hold a pretrial release hearing under subsection (f) only in one of the following circumstances: (i) Certain alleged narcotics offenses The person is charged with an offense for which a minimum term of imprisonment of ten years or more is prescribed in the Controlled Substances Act ( 21 U.S.C. 801 et seq.), the Controlled Substances